spring cloud
在搭建项目时,仅使用了eureka client,启动时报错:
Field optionalArgs in org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration required a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:Consider defining a bean of type 'com.netflix.discovery.AbstractDiscoveryClientOptionalArgs' in your configuration.
Process finished with exit code 1
在项目中搜索了下,发现AbstractDiscoveryClientOptionalArgs类其实是存在的。
百度了下原因,有人说是由于高版本的SpringBoot需要应用spring-boot-starter-web包,不然会出现上面异常;低版本是可以兼容的。
so,加上spring-boot-starter-web包,问题解决。
附上完整的POM文件
4.0.0 org.springframework.boot spring-boot-starter-parent2.4.3 com.example demo0.0.1-SNAPSHOT demo Demo project for Spring Boot Cloud 1.8 2020.0.1 org.springframework.boot spring-boot-starter-weborg.springframework.cloud spring-cloud-starter-netflix-eureka-clientorg.projectlombok lomboktrue org.springframework.boot spring-boot-starter-testtest org.springframework.cloud spring-cloud-dependencies${spring-cloud.version} pom import org.springframework.boot spring-boot-maven-pluginorg.projectlombok lombok



