首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >升级到Spring-Boot1.5.9(从1.3.x开始)- ClassNotFoundException for ServletRegistrationBean

升级到Spring-Boot1.5.9(从1.3.x开始)- ClassNotFoundException for ServletRegistrationBean
EN

Stack Overflow用户
提问于 2018-04-26 18:49:49
回答 1查看 512关注 0票数 0

我正在尝试升级到SpringBoot1.5.9,当它编译时,在运行时我得到了下面的异常。我试着转到下引,尝试更新Spring (Edgware,Brixton,等等)没有运气。我知道我的代码没有使用这个类(如果是这样的话,它不会编译)。我如何找到冒犯的依赖(如果是这样的)?我的pom.xml很大,有很多内部构件,所以发布这些东西是没有意义的。

代码语言:javascript
复制
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依赖关系:

代码语言:javascript
复制
    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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-27 20:43:41

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50050066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档