当前位置:

# spring-cloud-gateway打包运行报错,Error creating bean with name ‘discoveryLocatorProperties‘

访客 2024-04-23 827 0

spring-cloud-gateway打包运行报错,Errorcreatingbeanwithname‘discoveryLocatorProperties’

昨天试了无数次,每次idea上可以运行,但是打包成jar包,执行就报错:

Errorcreatingbeanwithname‘discoveryLocatorProperties’definedinclasspathresource[org/springframework/cloud/gateway/discovery/GatewayDiscoveryClientAutoConfiguration.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[org.springframework.cloud.gateway.discovery.DiscoveryLocatorProperties]:Factorymethod‘discoveryLocatorProperties’threwexception;nestedexceptionisjava.lang.NoClassDefFoundError:javax/validation/ValidationException

解决办法:在pom中还要加一个依赖:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId></dependency>

也就是,这样重新打包就正常运行啦,感谢国外某不知名网友

发表评论

  • 评论列表
还没有人评论,快来抢沙发吧~