我有一个现有的spring boot应用程序,运行正常。现在,我试图将其设置为eureka客户端,但是一旦我将maven依赖项添加到其中。应用程序无法启动
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
它开始显示错误
原因:java.lang.NoSuchMethodError:org.springframework.boot.builder.SpringApplicationBuilder。([Ljava / lang / Object;)V 在org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157) 在org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98) 在org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64) 在org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) 在org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) 在org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) 在org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) 在org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75) 在org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) 在org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:306) 在org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139)
这是我的主班文件代码的方式
@SpringBootApplication
public class EnterpriseSpringBootApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(EnterpriseSpringBootApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(EnterpriseSpringBootApplication.class);
}
}