org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is java.lang.NullPointerException
引入spring-cloud-starter-netflix-eureka-client和spring-boot-starter-web两个依赖的时候,会出现冲突。由于代码里面用了Spring MVC的Rest方式,而没有用spring-cloud-starter-netflix-eureka-client本身包含Jesery Rest方式。而导致报错
解决方法:
在spring-cloud-starter-netflix-eureka-client排出Jersey
如下:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<!-- 排除Jersey,用SpringMVC Rest方式-->
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client4</artifactId>
</exclusion>
</exclusions>
</dependency>