web-dev-qa-db-fra.com

Migration de Spring Boot 1.5 vers 2.0, impossible de démarrer l'application: Java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver

J'ai mis à niveau mon application Spring Boot existante, de springboot 1.5 à 2.0. Maintenant, je reçois un message d'erreur ci-dessous, lorsque j'essaie de déployer l'application. Veuillez aider.

Remarque: Je n'ai pas @ComponentScan, mais j'utilise @SpringBootApplication au package racine dans mon application. En outre, j'utilise la dernière version des dépendances d'Apache camel springboot.

De plus, si je supprime la dépendance ci-dessous, l'application se déploie bien, mais bien sûr, sans routeur Apache Camel initialisé!

<dependency>
            <groupId>org.Apache.camel</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>2.20.2</version>
</dependency>

Comment j'ai mis à jour: Modification de la version de springboot dans pom.xml Outil utilisé: STS (Spring Tool Suite)

14-03-2018 11:51:27.972-main-ERROR-SpringApplication - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.test.MyTestApp]; nested exception is Java.lang.IllegalStateException: Could not evaluate condition on org.Apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.Java:616)
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.Java:548)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.Java:184)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.Java:316)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.Java:233)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.Java:273)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.Java:93)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.Java:693)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:531)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.Java:140)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.Java:752)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.Java:388)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:327)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1246)
    at org.springframework.boot.SpringApplication.run(SpringApplication.Java:1234)
    at com.test.MyTestApp.main(MyTestApp.Java:27)
Caused by: Java.lang.IllegalStateException: Could not evaluate condition on org.Apache.camel.spring.boot.health.HealthCheckRoutesAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.Java:55)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.Java:109)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.Java:217)
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.Java:606)
    ... 15 common frames omitted
Caused by: Java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver
    at org.Apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator.isEnabled(HierarchicalPropertiesEvaluator.Java:49)
    at org.Apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator.evaluate(HierarchicalPropertiesEvaluator.Java:42)
    at org.Apache.camel.spring.boot.util.GroupCondition.getMatchOutcome(GroupCondition.Java:40)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.Java:47)
    ... 18 common frames omitted
Caused by: Java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver
    at Java.net.URLClassLoader.findClass(URLClassLoader.Java:381)
    at Java.lang.ClassLoader.loadClass(ClassLoader.Java:424)
    at Sun.misc.Launcher$AppClassLoader.loadClass(Launcher.Java:338)
    at Java.lang.ClassLoader.loadClass(ClassLoader.Java:357)
    ... 22 common frames omitted

Contenu de pom.xml ci-dessous:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.Apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.Apache.org/POM/4.0.0 http://maven.Apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.test</groupId>
    <artifactId>my-application</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>

    <name>my-application</name>
    <description>TEST Application</description>

    <!-- Spring 1.5 to 2.0 Migration -->
    <!-- <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> 
        <version>1.5.6.RELEASE</version> <relativePath /> lookup parent from repository 
        </parent> -->

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <Java.version>1.8</Java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-properties-migrator</artifactId>
            <scope>runtime</scope>
        </dependency> 

        <dependency>
            <groupId>com.vaadin.external.google</groupId>
            <artifactId>Android-json</artifactId>
            <version>0.0.20131108.vaadin1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
        <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-actuator</artifactId>
      <optional>true</optional>
      </dependency>
        <dependency>
            <groupId>org.Apache.camel</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>2.20.2</version>
        </dependency>
        <dependency>
            <groupId>org.Apache.camel</groupId>
            <artifactId>camel-jaxb</artifactId>
            <version>2.20.2</version>
        </dependency>
        <dependency>
            <groupId>org.Apache.camel</groupId>
            <artifactId>camel-test-spring</artifactId>
            <version>2.20.2</version>
        </dependency>
        <dependency>
            <groupId>org.Apache.activemq</groupId>
            <artifactId>activemq-camel</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.Apache.Tomcat</groupId>
                    <artifactId>Tomcat-jdbc</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.Apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>
        <dependency>
            <groupId>org.Apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.Apache.Tomcat.embed</groupId>
                    <artifactId>Tomcat-embed-websocket</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
        </dependency>

        <!-- Spring 1.5 to 2.0 Migration -->
        <!-- <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> 
            </dependency> -->

        <dependency>
            <groupId>org.Apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
        </dependency>

        <dependency>
            <groupId>com.Microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.activation/activation -->
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.mail/mail -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.Apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-Java-sources</id>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>./src/main/generated-sources</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>


        <finalName>test-app</finalName>
    </build>


</project>
11
Codeit

Apache Camel 2.20.2 est pris en charge pour Spring Boot 1.5 uniquement. Selon le site Web Apache Camel, ils étendront la prise en charge à la botte de printemps à partir de la version 2.22 (début de l'été 2018). Donc, pour résoudre, il suffit d'utiliser Spring Boot 1.5.10 uniquement pour l'instant. Merci à tous d'avoir vérifié/répondu. Liens de référence: http://camel.Apache.org/camel-2210-release.html

"This release supports only Spring Boot 1.5.x. Support for Spring Boot 2.0.x is coming in Camel version 2.22 which is planned for early summer 2018."

P.S. Sur http://start.spring.io/ (Passer à la version complète) vous pouvez vérifier si un projet Spring (Apache Camel) est compatible avec votre version Spring Boot. Actuellement, l'Initilizer montre

Apache Camel
Integration using Apache Camel
requires Spring Boot >=1.4.0.RELEASE and <2.0.0.M1
7
Codeit