Ayush Srivastava
Ayush Srivastava

Reputation: 474

Maven dependency conflicts in spring cloud

When i try to add the spring cloud dependencies my project gives the below errors which I am not able to solve because of some version conflicts.Please Help me identify the issue and solve this.

Hi have a spring boot project with:

pom.xml   
<dependencies>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
        <version>2.1.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        <version>1.4.6.RELEASE</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.6</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-xml</artifactId>
        <version>2.9.8</version>
    </dependency>
</dependencies>

I am getting the following errors with Loaded default TestExecutionListener class names from location exception and [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist exceptions.

 [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time 
 elapsed: 2.692 s <<< FAILURE! - in 
 com.package.packageApplicationTests
 [ERROR] contextLoads(com.package.packageApplicationTests)  Time 
 elapsed: 0.002 s  <<< ERROR!
 java.lang.IllegalStateException: Failed to load ApplicationContext
 Caused by: 
 org.springframework.beans.factory.BeanDefinitionStoreException: 
  Failed to process import candidates for configuration class 
  [com.package.packageApplication]; nested exception is 
  java.io.FileNotFoundException: class path resource 
  org/springframework/boot/autoconfigure
  /web/ServerPropertiesAutoConfiguration.class cannot be opened 
  because it does not exist
  Caused by: java.io.FileNotFoundException: class path resource 
  org/springframework/boot/autoconfigure/web/
  ServerPropertiesAutoConfiguration.class cannot be opened because it 
  does not exist

Upvotes: 1

Views: 1771

Answers (1)

Pablo Castro
Pablo Castro

Reputation: 144

Have you tried to remove the version tag following the springboot head version? Looks like Some of your dependencies is adding some incompatible dependencies between version.

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

Upvotes: 1

Related Questions