一. 项目启动不起来
很奇怪在另一台电脑可以,但是换了一台电脑就不行了,两台电脑的区别仅仅是idea编辑器不一样,一个是社区版,一个是专业版。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'discoveryLocatorProperties' defined in class path resource [org/springframework/cloud/gateway/discovery/GatewayDiscoveryClientAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.gateway.discovery.DiscoveryLocatorProperties]: Factory method 'discoveryLocatorProperties' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidationException
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.gateway.discovery.DiscoveryLocatorProperties]: Factory method 'discoveryLocatorProperties' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidationException
Caused by: java.lang.NoClassDefFoundError: javax/validation/ValidationException
解决方案:根据 Spring Boot 2.3 Release Notes ,Validation Starter不再包含在Web Start中,所以需要我们额外的引入Validation的依赖包。2.3版本以后Validation Starter不再包含在Web Start中,得额外引入:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>