Two Maven Dependency for conflicts of recent and old versions

We use the spring -data-dynamoDB project here , according to pom.xml they used the 1.6.9.1 version of aws-java-sdk , but I need to use the latest version of aws-java-sdk for my project to use some of its functions to implement Amazon s3 too. If I turn on his addiction,

<dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk</artifactId> <version>1.7.9</version> </dependency> 

I get the exception as follows:

 12:51:25.298 [main] DEBUG osbfsDefaultListableBeanFactory - Retrieved dependent beans for bean '(inner bean)': [_relProvider] 12:51:25.307 [main] ERROR oswcContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.hateoas.config.HypermediaSupportBeanDefinitionRegistrar$Jackson2ModuleRegisteringBeanPostProcessor#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_halObjectMapper': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.fasterxml.jackson.databind.ObjectMapper]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE] ....... ....... Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_halObjectMapper': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.fasterxml.jackson.databind.ObjectMapper]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1076) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE] ....... ....... 

I tried exceptions as follows, as well as the same result,

 <dependency> <groupId>org.socialsignin</groupId> <artifactId>spring-data-dynamodb</artifactId> <version>1.0.0-SNAPSHOT</version> <exclusions> <exclusion> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk</artifactId> </exclusion> </exclusions> </dependency> 

Can I use the latest version of aws-java-sdk in my project now? or else spring -data-dynamoDB pom.xml need to be updated, if so, only I can use it or what? Thanks to Michaellavelle for this amazing project. It helps me a lot to complete the DynamoDB part.

+8
java spring-data spring-data-rest maven amazon-web-services
source share
3 answers

Thank you @ user944849. The problem is that jackson libs is used in aws-java-sdk, which is a lower version, like in spring -data-rest-webmvc, and conflicts with it, therefore, excluding jackson libs from aws-java-sdk, build correctly. The solution I got is

 <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk</artifactId> <version>1.7.9</version> <exclusions> <exclusion> <artifactId>jackson-core</artifactId> <groupId>com.fasterxml.jackson.core</groupId> </exclusion> <exclusion> <artifactId>jackson-databind</artifactId> <groupId>com.fasterxml.jackson.core</groupId> </exclusion> <exclusion> <artifactId>jackson-annotations</artifactId> <groupId>com.fasterxml.jackson.core</groupId> </exclusion> </exclusions> </dependency> 

I cannot post an answer earlier due to reputation. This may be helpful to others who have stuck like me. Thanks.

+18
source share

Error NoClassDefFound for com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering . I searched this class in GrepCode and found that it is in the com.fasterxml.jackson.core:jackson-core library. I assume that the two versions of the aws-java-sdk library that you tried set different versions of the jackson-core library as transitive dependencies. Your application may be explicitly dependent on jackson-core , as well as an older version than the previous aws-java-sdk . The project should use a version of jackson-core that contains the requirePropertyOrdering method. You should be able to see all transitive dependencies by running mvn dependency:tree (or the equivalent in your IDE).

One fix is ​​to add the jackson-core library to the <dependencyManagement> block in the project POM (or parent POM) to make sure that the correct version is being used.

+2
source share

For some reason, jackson exception from aws-java did not work for me.

 java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z 

Looking at the problem, it seems that Jackson is unavailable, or we have the wrong version floating in the project. This method seems to have been added in 2.3.0, the latest version of Jackson. I added a dependency on the latest jackson version and my code is now happy.

 <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk-s3</artifactId> <version>1.9.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.3.0</version> </dependency> 

I'm not sure if annotations and data are needed. In addition, I am working on a huge project, so different forms of jackson can come from various other dependencies, jersey, google-http-client-jackson2. Thus, it is also wise to look at the maven dependency graph to see where any jackson comes from.

+2
source share

All Articles