Java 升级到Spring Boot 1.5.9(从1.3.x版)-ServletRegistrationBean的ClassNotFoundException

Java 升级到Spring Boot 1.5.9(从1.3.x版)-ServletRegistrationBean的ClassNotFoundException,java,spring,maven,spring-boot,dependencies,Java,Spring,Maven,Spring Boot,Dependencies,我试图升级到Spring Boot 1.5.9,当它编译时,我在运行时遇到以下异常。我尝试过切换到undertow,尝试过更新SpringCloud(Edgware、Brixton等),但运气不佳。我知道我的代码没有使用这个类(如果这样,它将不会编译)。我如何找到令人不快的依赖性(如果是这样的话)?我的pom.xml很大,有很多内部构件,所以发布整个文件是没有意义的 java.lang.IllegalStateException: Could not evaluate condition on

我试图升级到Spring Boot 1.5.9,当它编译时,我在运行时遇到以下异常。我尝试过切换到undertow,尝试过更新SpringCloud(Edgware、Brixton等),但运气不佳。我知道我的代码没有使用这个类(如果这样,它将不会编译)。我如何找到令人不快的依赖性(如果是这样的话)?我的pom.xml很大,有很多内部构件,所以发布整个文件是没有意义的

java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$EndpointWebMvcConfiguration due to org/springframework/boot/context/embedded/ServletRegistrationBean 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) ~[spring-boot-autoconfigure-1.5.9.RELEASE.jar!/:1.5.9.RELEASE] ......

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.ServletRegistrationBean
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_161]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_161]
    at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94) ~[lbossvc.jar:2.434.0]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_161]
    at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:1.8.0_161]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[?:1.8.0_161]
    at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[?:1.8.0_161]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) ~[spring-core-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) ~[spring-core-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) ~[spring-core-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570) ~[spring-core-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:425) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395) ~[spring-beans-4.3.13.RELEASE.jar!/:4.3.13.RELEASE]
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ManagementServerPort.hasCustomBeanDefinition(EndpointWebMvcAutoConfiguration.java:424) ~[spring-boot-actuator-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ManagementServerPort.hasCustomBeanDefinition(EndpointWebMvcAutoConfiguration.java:417) ~[spring-boot-actuator-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ManagementServerPort.get(EndpointWebMvcAutoConfiguration.java:368) ~[spring-boot-actuator-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$OnManagementMvcCondition.getMatchOutcome(EndpointWebMvcAutoConfiguration.java:345) ~[spring-boot-actuator-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-1.5.9.RELEASE.jar!/:1.5.9.RELEASE]
以下是我的Spring依赖项:

    org.springframework:spring-context:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-starter-netflix-archaius:jar:1.4.4.RELEASE:compile
[INFO]    org.springframework.data:spring-data-commons:jar:1.13.9.RELEASE:compile
[INFO]    org.springframework.restdocs:spring-restdocs-core:jar:1.1.2.RELEASE:test
[INFO]    org.springframework.cloud:spring-cloud-context:jar:1.3.3.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-commons:jar:1.3.3.RELEASE:compile
[INFO]    org.springframework:spring-context-support:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.security:spring-security-crypto:jar:4.2.3.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-starter-netflix-hystrix:jar:1.4.4.RELEASE:compile
[INFO]    org.springframework:spring-beans:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework:spring-expression:jar:4.3.13.RELEASE:compile
[INFO]    io.springfox:springfox-swagger-ui:jar:2.8.0:compile
[INFO]    org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO]    org.springframework:spring-aop:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.9.RELEASE:compile
[INFO]    io.springfox:springfox-swagger2:jar:2.8.0:compile
[INFO]    org.springframework:spring-core:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-web:jar:1.5.9.RELEASE:compile
[INFO]    io.springfox:springfox-spi:jar:2.8.0:compile
[INFO]    org.springframework.boot:spring-boot-starter-test:jar:1.5.9.RELEASE:test
[INFO]    org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO]    org.springframework:spring-jdbc:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-test:jar:1.5.9.RELEASE:test
[INFO]    org.springframework.boot:spring-boot-starter-actuator:jar:1.5.9.RELEASE:compile
[INFO]    io.springfox:springfox-schema:jar:2.8.0:compile
[INFO]    io.springfox:springfox-core:jar:2.8.0:compile
[INFO]    org.springframework.cloud:spring-cloud-starter:jar:1.3.3.RELEASE:compile
[INFO]    org.springframework.data:spring-data-keyvalue:jar:1.2.9.RELEASE:compile
[INFO]    org.springframework.security:spring-security-rsa:jar:1.0.3.RELEASE:compile
[INFO]    org.springframework.data:spring-data-redis:jar:1.7.5.RELEASE:compile
[INFO]    org.springframework:spring-oxm:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-configuration-processor:jar:1.5.9.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-undertow:jar:1.5.9.RELEASE:compile
[INFO]    org.springframework:spring-test:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-netflix-core:jar:1.4.4.RELEASE:compile
[INFO]    org.springframework.restdocs:spring-restdocs-mockmvc:jar:1.1.2.RELEASE:test
[INFO]    org.springframework.boot:spring-boot-actuator:jar:1.5.9.RELEASE:compile
[INFO]    org.springframework.retry:spring-retry:jar:1.0.3.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.9.RELEASE:test
[INFO]    io.springfox:springfox-swagger-common:jar:2.8.0:compile
[INFO]    io.springfox:springfox-spring-web:jar:2.8.0:compile
[INFO]    org.springframework:spring-web:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-log4j2:jar:1.5.9.RELEASE:compile
[INFO]    org.springframework:spring-tx:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile
[INFO]    org.springframework.cloud:spring-cloud-starter-hystrix:jar:1.4.4.RELEASE:compile
[INFO]    org.springframework:spring-jmx:jar:2.0.8:compile
[INFO]    org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.RELEASE:compile
[INFO]    org.springframework:spring-webmvc:jar:4.3.13.RELEASE:compile
[INFO]    org.springframework.boot:spring-boot-starter-aop:jar:1.5.9.RELEASE:compile

事实证明,我的假设是正确的——我的一个内部依赖项是从早期的Spring引导版本(上下文包vs web包)导入ServletRegistrationBean。有两种可能的修复方法,因为我不确定是否可以更新依赖项。一个是创建一个完全限定的类,该类只是使用旧包扩展ServletRegistrationBean,另一个是更新依赖项。这两种方法都能奏效,尽管前者非常粗糙。谢天谢地,我可以更新依亲代码,这就是我如何解决这个问题的