SpringBoot升级所遇到的坑们s1.5.x升级到2.1.x
下⾯总结从Spring Boot 1.5.15.Release版本升级到2.1.1.Release版本所遇到的问题,因为每个项⽬所依赖库的多少不同,所以有些我列出的问题可能你的产品没有遇到,或者你的问题我的产品没有遇到,问题的多少会有些许不同。
⽂章⽐较长,在此列出了所有我遇到的问题,如果您计划升级仅仅先了解⼀下攻略,可以主要看下⽬录,细节速览⼀下即可。如果是遇到了同样的问题,可以直接跳到您遇到的问题并查解决⽅案。
以下升级主要涵盖:Spring Boot, Spring Cloud,Flyway,Hikari,JPA,Zuul,Jackson,Mockito,RabbitMQ,Web Socket
废话不多说,直接上⼲货!
Spring Boot 版本升级
1. 修改pom⽂件,设置Spring Boot的版本信息
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/><!-- lookup parent from repository -->
</parent>
Spring Cloud版本升级(若没有使⽤到Spring Cloud,可以忽略这段)
2. 修改pom⽂件,设置Spring Cloud的版本信息
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Zuul升级后在maven中不到依赖的报错
Spring Cloud升级到2.x之后,Zuul的库包发⽣了变化,之前是spring-cloud-starter-zuul,2.x之后是spring-cloud-starter-netflix-zuul,多加了⼀层“netflix”。
默认会报此错误:
解决⽅案:修改pom⽂件,设置Zuul的依赖包名称
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
SpringBoot升级后ErrorController 类的package包位置变化导致报错
报错:
Error:(*,*) java: cannot find symbol
symbol: class ErrorController
location: package org.springframework.boot.autoconfigure.web
Error:(*, *) java: cannot find symbol
symbol: class ErrorController
原因:之前ErrorController在org.springframework.boot.autoconfigure.web.ErrorController,现在修改为 org.springframework.boot.ErrorController;
解决⽅案:修改import代码为:import org.springframework.boot.ErrorController;
JPA升级后 save⽅法报错:
报错:
Error:(*, *) java: method save in interface org.pository.CrudRepository<T,ID> cannot be applied to given types;
required: S
found: java.util.List&st.demo.dbmodel.UserSection>
reason: inferred type does not conform to upper bound(s)
inferred: java.util.List<st.dbmodel.UserSection>
upper bound(s): st.dbmodel.UserSection
原因:JPA升级后的Save接⼝发⽣变化
解决⽅案:使⽤saveAll⽅法代替save⽅法:testRepository.save(entity); --> testRepository.saveAll(entity);
JPA升级后 findOne⽅法报错:
报错:
Error:(63, 66) java: cannot find symbol
symbol: method findOne(java.lang.Long)
location: variable floorSectionRepository of type st.repository.FloorSectionRepository
Error:(83, 59) java: cannot find symbol
symbol: method findOne(java.lang.Long)
location: variable floorSectionRepository of type st.repository.FloorSectionRepository
原因:JPA升级后删掉了findOne⽅法
解决⽅案:使⽤findById(entity).orElse(null);代替findOne:testRepository.findOne(entity); --> testRepository.findById(entity).orElse(null);
JPA升级后 delete⽅法报错:
报错:
Error:(165, 62) java: incompatible types: java.lang.Integer cannot be converted to st.dbmodel.PrinterInfo
原因:JPA升级后重构了delete⽅法,之前delete⽅法参数是Id,现在是entity
解决⽅案:使⽤deleteById⽅法替换delete:testRepository.Id()); --> testRepository.Id());
升级后mockito库的 getArgumentAt() ⽅法报错
报错:
Error:(157, 49) java: cannot find symbol
symbol: method getArgumentAt(int,java.lang.Class<java.lang.Runnable>)
location: variable invocationOnMock of kito.invocation.InvocationOnMock
原因:mockito升级后,修改了此⽅法的实现,删除了这个⽅法
解决⽅案:使⽤getArgument(index);⽅法替换:ArgumentAt(0, Runnable.class); --> Argument(0);
升级后mockito库的ArgumentMatcher类的matches⽅法参数报错
报错:
Error:(74, 17) java: method argThat in kito.Matchers cannot be applied to given types;
required: kito.ArgumentMatcher<T>
found: st.RequestDetailMatcher
reason: cannot infer type-variable(s) T
(argument mismatch; st.RequestDetailMatcher cannot be converted kito.ArgumentMatcher<T>)
原因:mockito升级后,重构了matches⽅法,matches⽅法的参数变为泛型
解决⽅案:重新实现matches的Override⽅法:
升级前代码:
argThat(new ArgumentMatcher<Map<String, Object>>() {
@Override
public boolean matches(Object o) {
Map<String, Object> data = (Map<String, Object>) o;
("loginName").equals("ADIUSERNAME") && ("password").equals("ADIRESTPASSWORD") && ("timeToLive").equals(1440);
}
}),
升级后代码:
argThat(new ArgumentMatcher<Map<String, Object>>() {
@Override
public boolean matches(Map<String, Object> stringObjectMap) {
Map<String, Object> data = stringObjectMap
("loginName").equals("ADIUSERNAME") && ("password").equals("ADIRESTPASSWORD") && ("timeToLive").equals(1440);
}
}),
升级后mockito库的kito.Matchers废弃的问题
解决⽅案:修改 kito.Matchers 成 kito.ArgumentMatcher
Spring Boot升级后flyway报错不到类:figuration.FluentConfiguration
报错:
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flywayInitializer
at org.springframework.dition.SpringBootCondition.matches(SpringBootCondition.java:64)
at t.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
at t.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:181) at t.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141) at t.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)
at t.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327)
at t.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at t.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) at t.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at t.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691)
at t.fresh(AbstractApplicationContext.java:528)
at org.springframework.boot.fresh(ServletWebServerApplicationContext.java:142)
at org.springframework.fresh(SpringApplication.java:775)
at org.springframework.freshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at st.Application.main(Application.java:28)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:497)
at org.springframework.start.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@14dad5dc]
at org.springframework.DeclaredMethods(ReflectionUtils.java:686)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:583)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:568)
at org.springframework.UniqueDeclaredMethods(ReflectionUtils.java:626)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$$Lambda$160/618219761.apply(Unknown Source)
at urrent.ConcurrentHashMapputeIfAbsent(ConcurrentHashMap.java:1660)
at org.springframework.beans.factory.TypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:721)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:662)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:630)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1518)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1023)
at org.springframework.dition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:195)
at org.springframework.dition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:159)
at org.springframework.dition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:152)
at org.springframework.dition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:140)
at org.springframework.dition.BeanTypeRegistry$$Lambda$158/1059921170.accept(Unknown Source)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at org.springframework.dition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:135)
at org.springframework.NamesForType(BeanTypeRegistry.java:97)
at org.springframework.llectBeanNamesForType(OnBeanCondition.java:298)
at org.springframework.BeanNamesForType(OnBeanCondition.java:289)
at org.springframework.BeanNamesForType(OnBeanCondition.java:278)
at org.springframework.MatchingBeans(OnBeanCondition.java:189)
at org.springframework.MatchOutcome(OnBeanCondition.java:160)
at org.springframework.dition.SpringBootCondition.matches(SpringBootCondition.java:47)
... 22 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/flywaydb/core/api/configuration/FluentConfiguration
at java.DeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.DeclaredMethods(Class.java:1975)
at org.springframework.DeclaredMethods(ReflectionUtils.java:668)
... 46 common frames omitted
Caused by: java.lang.ClassNotFoundException: figuration.FluentConfiguration
at java.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 50 common frames omitted
Process finished with exit code 0
原因:版本与SpringBoot版本不兼容
解决⽅案:删除flyway的固定版本,通过SpringBoot的spring-boot-starter-parent进⾏依赖的版本⾃动管理
修改前代码:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>4.2.0</version>
</dependency>
修改后代码:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
Spring Boot升级后配置⽂件配置sources.cache-period, ipped废弃的报错
报错:
Binding to target [Bindable@5ff328d6 type = org.springframework.boot.autoconfigure.web.ResourceProperties, value = 'provided', annotations = arr
ay<Annotation>
[@org.t.properties.ConfigurationProperties(sources, sources, ignoreInvalidFields=false, ignoreUnknownFields=false)]] failed: Property: sources.cache-period
Value: 604800
Origin: URL [file:./config/application.properties]:44:31
Reason: The elements [sources.ipped] were left unbound.
Property: ipped
Value: true
Origin: URL [file:./config/application.properties]:46:32
Reason: The elements [sources.ipped] were left unbound.
Action:
Update your application's configuration
原因:参数sources.cache-period, ipped已经被废弃,不再使⽤,删除或使⽤替代⽅案
解决⽅案:删除,并使⽤如下配置替换,在application.properties⽂件中修改
修改前代码:
修改后代码:
SpringBoot升级后使⽤HiKari数据库连接重试机制替换废弃了的Tomcat.JDBC的Retry机制
Tomcat.JDBC有重连数据库机制,当数据库服务还没有启动时,会导致SpringBoot服务启动失败,这时Tomcat.JDBC的重试机制会⼀直尝试连接数据库,不会导致服务崩溃,待到数据库服务恢复后重新连接。
##wait postgre SQL service start, after 5 minutes (3000 milliseconds) still cannot connect to database,  will throw database cannot connect exception.
spring.datasource.hikari.initializationFailTimeout=300000
SpringBoot升级后RabbitMQ报错:
报错:
t.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.Refresh(ServletWebServerApplicationContext.java:157)
at t.fresh(AbstractApplicationContext.java:540)
at org.springframework.boot.fresh(ServletWebServerApplicationContext.java:142)
at org.springframework.fresh(SpringApplication.java:775)
at org.springframework.freshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at st.Application.main(Application.java:28)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:497)
at org.springframework.start.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.at.TomcatWebServer.initialize(TomcatWebServer.java:125)
at org.springframework.at.TomcatWebServer.<init>(TomcatWebServer.java:86)
at org.springframework.TomcatWebServer(TomcatServletWebServerFactory.java:414)
at org.springframework.WebServer(TomcatServletWebServerFactory.java:174)
at org.springframework.boot.ateWebServer(ServletWebServerApplicationContext.java:181)
at org.springframework.boot.Refresh(ServletWebServerApplicationContext.java:154)
... 13 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.springframework.dpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'org.springframework.boot.actuate.autoconfigure.amqp.RabbitHealthIndicatorAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource
[org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]:
Unsatisfied dependency expressed through method 'rabbitTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Initialization of bean failed; nested exception is
java.lang.NoClassDefFoundError: com/rabbitmq/client/impl/MicrometerMetricsCollector
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:607)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
at org.springframework.beans.factory.ateBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
at org.springframework.beans.factory.ateBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$Object(Unknown Source)
at org.springframework.beans.factory.Singleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.Bean(AbstractBeanFactory.java:
204)
at org.springframework.boot.web.OrderedBeansOfType(ServletContextInitializerBeans.java:235)
at org.springframework.boot.web.OrderedBeansOfType(ServletContextInitializerBeans.java:226)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:101)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:88)
at org.springframework.boot.ServletContextInitializerBeans(ServletWebServerApplicationContext.java:261)
at org.springframework.boot.t.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234)
at org.springframework.boot.t.ServletWebServerApplicationContext$$Lambda$Startup(Unknown Source)
spring framework
at org.springframework.Startup(TomcatStarter.java:54)
at org.StandardContext.startInternal(StandardContext.java:5098)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.ContainerBase$StartChild.call(ContainerBase.java:1432)
at org.ContainerBase$StartChild.call(ContainerBase.java:1422)
at urrent.FutureTask.run(FutureTask.java:266)
at at.util.ute(InlineExecutorService.java:75)
at urrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.ContainerBase.startInternal(ContainerBase.java:944)
at org.StandardHost.startInternal(StandardHost.java:831)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.ContainerBase$StartChild.call(ContainerBase.java:1432)
at org.ContainerBase$StartChild.call(ContainerBase.java:1422)
at urrent.FutureTask.run(FutureTask.java:266)
at at.util.ute(InlineExecutorService.java:75)
at urrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.ContainerBase.startInternal(ContainerBase.java:944)
at org.StandardEngine.startInternal(StandardEngine.java:261)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.StandardServer.startInternal(StandardServer.java:801)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:372)
at org.springframework.at.TomcatWebServer.initialize(TomcatWebServer.java:106)
... 18 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.dpoint.web.ServletEndpointRegistrar]: Factory method
'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint'
defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method
'healthEndpoint' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path
resource [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry'
threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'org.springframework.boot.actuate.autoconfigure.amqp.RabbitHealthIndicatorAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource
[org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'rabbitTemplate'
parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource
[org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Initialization of bean failed; nested exception is
java.lang.NoClassDefFoundError: com/rabbitmq/client/impl/MicrometerMetricsCollector
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
... 60 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1; nested
exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry'
threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'org.springframework.boot.actuate.autoconfigure.amqp.RabbitHealthIndicatorAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource
[org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'rabbitTemplate'
parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource
[org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]: Initialization of bean failed; nested exception is
java.lang.NoClassDefFoundError: com/rabbitmq/client/impl/MicrometerMetricsCollector
at org.springframework.beans.factory.ateArgumentArray(ConstructorResolver.java:769)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
at org.springframework.beans.factory.ateBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
at org.springframework.beans.factory.ateBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$Object(Unknown Source)
at org.springframework.beans.factory.Singleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.Bean(AbstractBeanFactory.java:199)
at t.Bean(AbstractApplicationContext.java:1083)
at org.springframework.dpoint.ateEndpointBean(EndpointDiscoverer.java:149)
at org.springframework.dpoint.ateEndpointBeans(En
dpointDiscoverer.java:136)
at org.springframework.dpoint.annotation.EndpointDiscoverer.discoverEndpoints(EndpointDiscoverer.java:125)
at org.springframework.dpoint.Endpoints(EndpointDiscoverer.java:119)
at
org.springframework.boot.dpoint.web.ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.servletEndpointRegistrar(ServletEndpoi at
org.springframework.boot.dpoint.web.ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration$$EnhancerBySpringCGLIB$$48a30ab0 at
org.springframework.boot.dpoint.web.ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration$$EnhancerBySpringCGLIB$$48a30ab0 at lib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at t.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
at
org.springframework.boot.dpoint.web.ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration$$EnhancerBySpringCGLIB$$48a30ab0 flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 61 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource
[org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry'
threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'org.springframework.boot.actuate.autoconfigure.amqp.RabbitHealthIndicatorAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rabbitTemplate' defined in class path resource
[org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'rabbitTemplate'
parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitConnectionFactory' defined in class path resource
[org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitConnectionFactoryCreator.class]:
Initialization of bean failed; nested exception is
java.lang.NoClassDefFoundError: com/rabbitmq/client/impl/MicrometerMetricsCollector
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:607)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
at org.springframework.beans.factory.ateBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
at org.springframework.beans.factory.ateBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$Object(Unknown Source)
at org.springframework.beans.factory.Singleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.Bean(AbstractBeanFactory.java:199)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。