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>