I am defining beans using #Bean annotation and trying to wire them using name , but receiving an exception.
Complete Example
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import com.fasterxml.jackson.databind.ObjectMapper;
#SpringBootApplication
#ComponentScan({"com.example"})
public class SampleSpringBootApplication {
public static void main(String[] args) {
SpringApplication.run(SampleSpringBootApplication.class, args);
}
#Bean
public ObjectMapper scmsObjectMapper() {
com.fasterxml.jackson.databind.ObjectMapper responseMapper = new com.fasterxml.jackson.databind.ObjectMapper();
return responseMapper;
}
#Bean
public ObjectMapper scmsWriteObjectMapper() {
com.fasterxml.jackson.databind.ObjectMapper responseMapper = new com.fasterxml.jackson.databind.ObjectMapper();
return responseMapper;
}
}
Controller
package com.example;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class SampleController {
#RequestMapping(method={RequestMethod.GET}, value="sample/hello", produces=MediaType.APPLICATION_JSON_VALUE)
#ResponseStatus(HttpStatus.OK)
public #ResponseBody ResponseEntity<String> getCart() {
return new ResponseEntity<String>("Hello", HttpStatus.OK);
}
}
build.gradle
buildscript {
ext {
springBootVersion = '1.2.7.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE')
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
jar {
baseName = 'Sample-SpringBoot'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile("org.springframework.boot:spring-boot-starter-web:1.2.3.RELEASE")
compile('com.fasterxml.jackson.core:jackson-databind:2.5.1')
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}
Exception
Caused by:
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No
qualifying bean of type [com.fasterxml.jackson.databind.ObjectMapper]
is defined: expected single matching bean but found 2:
scmsObjectMapper,scmsWriteObjectMapper
By default, Spring Boot defines a bean of type MappingJackson2HttpMessageConverter and tries to inject an ObjectMapper into it. This typically allows you to simply declare an ObjectMapper #Bean, configure it any way you need to, and have Spring Boot do the rest for you.
Here, this has backfired because you declare two of them.
One solution, as described in the documentation, is to annotate the #Bean definition of the one you want injected as #Primary.
If you want to replace the default ObjectMapper completely, define a
#Bean of that type and mark it as #Primary.
For example,
#Bean
#Primary
public ObjectMapper scmsObjectMapper() {
com.fasterxml.jackson.databind.ObjectMapper responseMapper = new com.fasterxml.jackson.databind.ObjectMapper();
return responseMapper;
}
Spring Boot will use that one.
Alternatively, you can declare your own MappingJackson2HttpMessageConverter bean definition and configure everything internally. From the same documentation
Finally, if you provide any #Beans of type
MappingJackson2HttpMessageConverter then they will replace the default
value in the MVC configuration.
For example (taken from here)
#Bean
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
jsonConverter.setObjectMapper(objectMapper);
return jsonConverter;
}
Related
I am unable to configure log4j2 with java.util.properties. I always get this message "tatusLogger No Log4j 2 configuration file found". Please see my logger class. I am reading the log4j2 properties from two files.
I will be attaching my code to this post.
package my.common.logger;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory;
import org.apache.logging.log4j.util.PropertiesUtil;
public class MyLogger {
private static boolean configured = false;
private static Logger logger;
static {
System.setProperty("log4j.configurationFactory", "my.common.logger.JCFLog4JConfigurationFactory");
}
private static void readConfiguration() throws Exception {
LoggerContext context = (LoggerContext) org.apache.logging.log4j.LogManager.getContext(false);
Configuration configuration = ConfigurationFactory.getInstance().getConfiguration(context, createConfigurationSource());
configuration.start();
Configurator.reconfigure();
configured = true;
}
public static Logger getLogger(String className) {
try {
if (!configured) readConfiguration();
return org.apache.log4j.LogManager.getLogger(className);
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
private static ConfigurationSource createConfigurationSource()
{ Properties p = new Properties();
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream in = null;
try {
p.putAll(<Read from File 1>);
p.putAll(<Read from File 2>);
p.store(out, null);
} catch (IOException e) {
e.printStackTrace();
}
in = new ByteArrayInputStream(out.toByteArray());
ConfigurationSource configSrc = null;
try {
configSrc = new ConfigurationSource(in);
}
catch (IOException i)
{
i.printStackTrace();
}
return configSrc;
}
}
Here is Config Factory Code:
package nj.aoc.ito.cmfw.common.logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory;
public class MyLog4JConfigurationFactory extends ConfigurationFactory {
public MyLog4JConfigurationFactory() {
}
#Override
public Configuration getConfiguration(LoggerContext ctx, ConfigurationSource source) {
PropertiesConfigurationFactory factory = new PropertiesConfigurationFactory();
return factory.getConfiguration(ctx, source);
}
#Override
protected String[] getSupportedTypes() {
return new String[]{".properties", "*"};
}
}
Any idea what I might be doing wrong?
Thanks
Nags
I have the following implementation:
public interface BusinessResource {
#RequiresAuthorization
public ResponseEnvelope getResource(ParamObj param);
}
and
#Component
public class BusinessResourceImpl implements BusinessResource {
#Autowired
public Response getResource(ParamObj param) {
return Response.ok().build();
}
}
and
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
#Aspect
#Component
public class AuthorizerAspect {
protected static final Logger LOGGER =
LoggerFactory.getLogger(AuthorizerAspect.class);
#Autowired
public AuthorizerAspect() {
LOGGER.info("Break point works here..." +
"so spring is creating the aspect as a component...");
}
#Around(value="#annotation(annotation)")
public Object intercept(ProceedingJoinPoint jp,
RequiresAuthorization annotation) throws Throwable {
LOGGER.info("BEGIN");
jp.proceed();
LOGGER.info("END");
}
}
The maven dependencies are properly configured with the spring-boot-starter-aop dependency. So what happens is that AuthorizerAspect won't intercept around the getResource method if the #RequiresAuthorization is used on the declared method of the BusinessResource interface, but if I change the implementation to annotate the same method now in the BusinessResourceImpl class, the aspect will take place.
NOTE: With the annotation in the interface level, the proxy isn't even created, whereas the annotation being placed in the implementation level will create a proxy for the resource.
Question is: Is there a way to advice objects which the annotation is present just on the interface?
May this alternative be useful for those who like me found no direct approach to sort that limitation on Spring AOP through proxies:
public interface BusinessResource {
#RequiresAuthorization
public ResponseEnvelope getResource(ParamObj param);
}
And
#Component
public class BusinessResourceImpl implements BusinessResource {
#Autowired
public Response getResource(ParamObj param) {
return Response.ok().build();
}
}
And
import import org.aopalliance.intercept.MethodInvocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
#Configuration
public class AuthorizerAspect {
protected static final Logger LOGGER =
LoggerFactory.getLogger(AuthorizerAspect.class);
#Autowired
public AuthorizerAspect() {
LOGGER.info("Break point works here..." +
"so spring is creating the aspect as a component...");
}
public Object invoke(MethodInvocation invocation) throws Throwable {
LOGGER.info("BEGIN");
invocation.proceed();
LOGGER.info("END");
}
#Bean
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
return new DefaultAdvisorAutoProxyCreator();
}
#Bean("requiresAuthorizationPointcut")
public AbstractPointcutAdvisor createPointcut() {
return new AbstractPointcutAdvisor() {
private static final long serialVersionUID = 4733447191475535406L;
#Override
public Advice getAdvice() {
return AuthorizerAspect.this;
}
#Override
public Pointcut getPointcut() {
return new StaticMethodMatcherPointcut() {
#Override
public boolean matches(Method method, Class<?> targetClass) {
if (method.isAnnotationPresent(RequiresAuthorization.class)) {
return true;
}
if (method.getDeclaringClass().isInterface()) {
String methodName = method.getName();
try {
Method targetMethod = targetClass.getMethod(methodName, method.getParameterTypes());
return targetMethod != null && targetMethod.isAnnotationPresent(RequiresAuthorization.class);
} catch (NoSuchMethodException |
SecurityException e) {
LOGGER.debug("FAILURE LOG HERE",
e.getMessage());
return false;
}
}
return method.isAnnotationPresent(RequiresAuthorization.class);
}
};
}
};
}
}
So as you'll notice, we're sorting it by using method interceptors.
I'm installing fbsdk to my react-native apps, i ran the following commands
npm install react-native-fbsdk#0.6.0 --save
react-native link react-native-fbsdk
After successfully installed i run react-native run-android and i got the following result
Here is my changes
In MainApplication.js
package com.ddc;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage(),
new FBSDKPackage(mCallbackManager)
);
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
// If you want to use AppEventsLogger to log events.
AppEventsLogger.activateApp(this);
}
}
In MainActivity.js
package com.ddc;
import com.facebook.react.ReactActivity;
import android.content.Intent;
public class MainActivity extends ReactActivity {
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
#Override
protected String getMainComponentName() {
return "DDC";
}
}
After that i modify the build.gradle, because after i run react-native link react-native-fbsdk it doesn't modify the file
repositories {
mavenCentral()
}
dependencies {
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.facebook.android:facebook-android-sdk:4.+'
}
How can i accept the agreement ?
your ANDROID_HOME variable is not properly set. fix that.
Solution via console using sdkmananger:
yes | sudo sdkmanager --licenses
Source - Automatically accept all SDK licences
In my spring boot application, I have multiple Rest Controllers and need to generate swagger for each controller seperately.
By using below Docket config for each controller in my spring boot application class, i am able to download controller specific swagger by going to /v2/api-docs?group=ai where i = 1 to n
However in swagger-ui.html, when i select a1(/v2/api-docs?group=a1), it shows path as "/api/a1/a1", while selecting a2(/v2/api-docs?greoup=a2), it shows correct path i.e. /api/a2
I have tried changing in Docket ,paths regex to absolute e.g. "api/a1" etc but that didn't help.
#Bean
public Docket a1Api() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("a1")
.apiInfo(a1Info())
.select().apis(RequestHandlerSelectors.any())
.paths(regex("/api/a1.*"))
.build()
.pathMapping("/");
}
#Bean
public Docket a2Api() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("a2")
.apiInfo(a1Info())
.select().apis(RequestHandlerSelectors.any())
.paths(regex("/api/a2.*"))
.build()
.pathMapping("/");
}
private ApiInfo a1Info() {
return new ApiInfoBuilder()
.title("a1 Swagger 2.0")
.description("a1")
.license("a1")
.version("1.0")
.build();
}
private ApiInfo a2Info() {
return new ApiInfoBuilder()
.title("a2 Swagger 2.0")
.description("a2")
.license("a2")
.version("1.0")
.build();
}
Rest Controllers
#RestController
#Api(tags = "A1")
#RequestMapping("/api/a1")
public class a1Controller {
#ApiOperation(value = "a1")
#RequestMapping(value = "", method = RequestMethod.POST)
public a1Response invoke(#RequestBody a1Request va1Request) {
.....;
}
}
#RestController
#Api(tags = "An")
#RequestMapping("/api/an")
public class a1Controller {
#ApiOperation(value = "an")
#RequestMapping(value = "", method = RequestMethod.POST)
public anResponse invoke(#RequestBody anRequest vanRequest) {
.....;
}
}
Any idea how can i address this....
i am using springfox swagger version 2.6.1
You can add multiple controller class using following Swagger Configuration:
1) Create a Swagger Configuration Class.
2) Then specify the base package of controllers.
import java.util.Collections;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
#Configuration
#EnableSwagger2
public class SwaggerConfig
{
private static final ApiInfo DEFAULT_API_INFO = null; //Swagger info
#Bean
public Docket api()
{
return new Docket(DocumentationType.SWAGGER_2)
.forCodeGeneration(Boolean.TRUE)
.select()
.apis(RequestHandlerSelectors.basePackage("com.user.controller"))
.paths(PathSelectors.any())
.paths(Predicates.not(PathSelectors.regex("/logout.*")))
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfo(
"REST API",
"REST description of API.",
"API TOS",
"Terms of service",
new Contact("Rajib Garai", "https://www.linkedin.com/in/rajibgarai90/", "90rajibgarai#gmail.com"),
"License of API", "API license URL", Collections.emptyList());
}
}
Here is the code i wrote to find and automatically create Docket on runtime per controller,
also has a Default Docket to show all in one group.
#Configuration
#EnableSwagger2
public class SwaggerConfig {
#Autowired
ConfigurableApplicationContext context;
//Default Docket to show all
#Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(metaData())
.forCodeGeneration(Boolean.TRUE)
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
.paths(PathSelectors.any())
.paths(Predicates.not(PathSelectors.regex("/error.*")))
.build();
}
//Creating Docket Dynamically per Rest Controller
#PostConstruct
public void postConstruct() throws ClassNotFoundException {
ClassPathScanningCandidateComponentProvider provider
= new ClassPathScanningCandidateComponentProvider(false);
provider.addIncludeFilter(new AnnotationTypeFilter(RestController.class));
for (BeanDefinition beanDef : provider.findCandidateComponents("com.blah.blah.package")) {
Class<?> cl = Class.forName(beanDef.getBeanClassName());
RequestMapping requestMapping = cl.getAnnotation(RequestMapping.class);
if (null != requestMapping && null != requestMapping.value() && requestMapping.value().length > 0) {
String resource_group = requestMapping.value()[0];
SingletonBeanRegistry beanRegistry = context.getBeanFactory();
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.groupName(resource_group)
.apiInfo(metaData())
.forCodeGeneration(Boolean.TRUE)
.select()
//.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
.paths(PathSelectors.regex(resource_group + ".*"))
.paths(Predicates.not(PathSelectors.regex("/error.*")))
.build();
beanRegistry.registerSingleton(cl.getSimpleName() + "_docket_api", docket);
}
}
}
private ApiInfo metaData() {
return new ApiInfoBuilder()
.title("some Title Here")
.description("Some Desciption")
.version("1.0")
.contact(new Contact("Asad Abdin", "", "asadabdin#gmail.com"))
.build();
}
I am porting jackson 1.6 code to jackson 2 and stumbled upon a deprecated code.
What i did in jackson 1.6 is:
CustomDeserializerFactory sf = new CustomDeserializerFactory();
mapper.setDeserializerProvider(new StdDeserializerProvider(sf));
sf.addSpecificMapping(BigDecimal.class, new BigDecimalDeserializer());
t = mapper.readValue(ts, X[].class);
Anyone knows how to do it in jackson 2?
To add a factory--not just a deserializer--don't use SimpleModule. Create your own Module and within it create a Deserializers object that is added to the SetUpContext. The Deserializers object will have access to similar methods that the factory did where you can get extra type information about the deserializer needed.
It will look something like this (note that it doesn't need to be an inner class):
public class MyCustomCollectionModule extends Module {
#Override
public void setupModule(final SetupContext context) {
context.addDeserializers(new MyCustomCollectionDeserializers());
}
private static class MyCustomCollectionDeserializers implements Deserializers {
...
#Override
public JsonDeserializer<?> findCollectionDeserializer(final CollectionType type, final DeserializationConfig config, final BeanDescription beanDesc, final TypeDeserializer elementTypeDeserializer, final JsonDeserializer<?> elementDeserializer) throws JsonMappingException {
if (MyCustomCollection.class.equals(type.getRawClass())) {
return new MyCustomCollectionDeserializer(type);
}
return null;
}
...
}
}
In Jackson 2.0:
Create a Module (usually SimpleModule)
Register custom handlers with it.
Call ObjectMapper.registerModule(module);.
This is available on Jackson 1.x as well (since 1.8 or so).
Here is an example of registering a module (in this case Joda date handling) in Jackson 2.x:
ClientConfig clientConfig = new DefaultClientConfig();
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JodaModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
JacksonJsonProvider provider = new JacksonJsonProvider();
provider.configure(SerializationFeature.INDENT_OUTPUT, true);
provider.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
provider.setMapper(mapper);
clientConfig.getSingletons().add(provider);
Client client = Client.create(clientConfig);
Exemplifying #StaxMan answer
Basically you need to create a module (SimpleModule), add a deserializer and register this module
final SimpleModule sm = new SimpleModule();
sm.addDeserializer(Date.class, new JsonDeserializer<Date>(){
#Override
public Date deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException {
try {
System.out.println("from my custom deserializer!!!!!!");
return new SimpleDateFormat("yyyy-MM-dd").parse(p.getValueAsString());
} catch (ParseException e) {
System.err.println("aw, it fails: " + e.getMessage());
throw new IOException(e.getMessage());
}
}
});
final CreationBean bean = JsonUtils.getMapper()
.registerModule(sm)
// .setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"))
.readValue("{\"dateCreation\": \"1995-07-19\"}", CreationBean.class);
Here a fully example
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
/**
* #author elvis
* #version $Revision: $<br/>
* $Id: $
* #since 8/22/16 8:38 PM
*/
public class JackCustomDeserializer {
public static void main(String[] args) throws IOException {
final SimpleModule sm = new SimpleModule();
sm.addDeserializer(Date.class, new JsonDeserializer<Date>(){
#Override
public Date deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException {
try {
System.out.println("from my custom deserializer!!!!!!");
return new SimpleDateFormat("yyyy-MM-dd").parse(p.getValueAsString());
} catch (ParseException e) {
System.err.println("aw, it fails: " + e.getMessage());
throw new IOException(e.getMessage());
}
}
});
final CreationBean bean = JsonUtils.getMapper()
.registerModule(sm)
// .setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"))
.readValue("{\"dateCreation\": \"1995-07-19\"}", CreationBean.class);
System.out.println("parsed bean: " + bean.dateCreation);
}
static class CreationBean {
public Date dateCreation;
}
}