使用spring-boot-starter-parent v2.0.x应用程序无法启动,但在1.5.14上可以正常使用

时间:2018-07-26 10:30:40

标签: spring-boot spring-boot-starter

使用 spring-boot-starter-parent 的v1.5.14,该应用程序可以正常启动,只需将其更改为v2.0.x即可将其破坏。 我收到以下错误:

`[main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:358)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
    at com.athena.collector.decisions.application.Application.main(Application.java:57)
([Ljava/lang/Object;)V`



我确实阅读了SpringApplicationBuilder for 2.x中的更改。但是不确定如何解决它。
这是启动片段

@SpringBootApplication(scanBasePackages = {"com.xyz", "com.abc"})
@EntityScan("com.xyz")
@EnableJpaRepositories("com.xyz")
@EnableAsync
public class Application {

@Autowired 
AppConfigurationProperties applicationPropertiesWrapper;

public static void main(final String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}


我缺少基本的东西吗?任何我应该阅读的东西的指针?

相关的Maven依赖项如下:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>**2.0.3.RELEASE**</version>
        <!-- <version>1.5.14.RELEASE</version>  -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
</dependencies>

1 个答案:

答案 0 :(得分:0)

问题是由于所引用的版本存在一些冲突。另一个依赖项是使用一组不同的与弹簧相关的罐子。 Ive完全解决问题后,应更新以更多详细信息。