将 Spring boot 1.5 迁移到 2.0,无法启动应用程序获取:java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver [英] Migrated Spring boot 1.5 to 2.0, unable to start app getting: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver

查看:37
本文介绍了将 Spring boot 1.5 迁移到 2.0,无法启动应用程序获取:java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将现有的 Spring Boot 应用程序从 springboot 1.5 升级到了 2.0.现在,当我尝试部署应用程序时,我收到以下错误消息.请帮忙.

I upgraded my existing working Spring Boot application, from springboot 1.5 to 2.0. Now, I am getting below error message, when I try to deploy the application. Please help.

注意:我没有@ComponentScan,而是在我的应用程序的根包中使用@SpringBootApplication.另外,我正在使用最新版本的 apache camel springboot 依赖项.

Note: I don't have @ComponentScan, instead I am using @SpringBootApplication at root package in my application. Also, I am using the latest version of apache camel springboot dependencies.

另外,如果我删除以下依赖项,应用程序部署正常,但当然,没有初始化 Apache Camel 路由器!

Also, if I remove the below dependency, the application deploys fine, but ofcourse, without Apache Camel router initialized!

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

我是如何更新的:更改 pom.xml 中的 springboot 版本使用的工具:STS(Spring Tool Suite)

How I did update: Changed the springboot version in pom.xml Tool used: 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

以下pom.xml的内容:

Contents of pom.xml below:

<?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>

推荐答案

解决了这个问题.Apache Camel 2.20.2 仅支持 Spring Boot 1.5.根据 Apache Camel 网站,他们将从 2.22(2018 年初夏)开始将支持扩展到 Spring Boot.所以要解决,现在只需要使用spring boot 1.5.10.感谢大家检查/回复.参考链接:http://camel.apache.org/camel-2210-release.html

Got this resolved.The Apache Camel 2.20.2 is supported for spring boot 1.5 only. As per Apache Camel website, they will extend support to spring boot starting with 2.22 (early summers 2018). So to resolve, just need to use spring boot 1.5.10 only for now. Thanks all for checking / responding. Reference Links: 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."

附:在 http://start.spring.io/ (切换到完整版) 您可以检查 Spring Project(Apache Camel) 是否与您的 Spring Boot 版本兼容.目前 Initilizer 显示

P.S. At http://start.spring.io/ (Switch to the full version) you can check if a Spring Project(Apache Camel) is compatible with your Spring Boot version. Currently the Initilizer shows

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

这篇关于将 Spring boot 1.5 迁移到 2.0,无法启动应用程序获取:java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆