【问题标题】:With spring-boot-starter-parent v2.0.x app does not start, while it works fine with 1.5.14使用 spring-boot-starter-parent v2.0.x 应用程序无法启动,而它在 1.5.14 中运行良好
【发布时间】:2018-07-26 10:30:40
【问题描述】:

使用 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 中的更改。但不确定如何修复它。
这里是启动sn -p

@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>

【问题讨论】:

  • 添加您的代码并发布完整的堆栈跟踪,而不仅仅是一个 sn-p。

标签: spring-boot spring-boot-starter


【解决方案1】:

问题是由于引用的版本存在冲突。另一个依赖项是使用一组不同的 spring 相关 jar。当我完全解决问题后,将更新更多细节。

【讨论】:

    猜你喜欢
    • 2020-11-06
    • 2020-02-19
    • 1970-01-01
    • 2020-07-27
    • 2020-05-23
    • 1970-01-01
    • 2020-12-18
    • 2017-05-25
    • 2021-11-25
    相关资源
    最近更新 更多