【问题标题】:ERROR org.springframework.boot.SpringApplication - Application run failed错误 org.springframework.boot.SpringApplication - 应用程序运行失败
【发布时间】:2020-12-18 22:00:01
【问题描述】:

我正在尝试在 Spring 数据流中实现 POC。我正在使用“spring-cloud-starter-dataflow-server-local”依赖项在本地创建数据流服务器。但它给出了以下错误:

 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:161)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:102)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:68)
    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:76)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
    at com.ms.batch_ui.App.main(App.java:14)

下面是pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ms</groupId>
    <artifactId>abc-ui</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>abc-ui</name>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
    </parent>
    <properties>
        <java.version>8</java.version>
        <h2.version>1.4.193</h2.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-dataflow-server-local</artifactId>
            <version>1.6.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
    </dependencies>
</project>

我有非常基本的 java 文件来启动应用程序

@EnableDataFlowServer
@SpringBootApplication
public class App {

    public static void main(String[] args) {
        SpringApplication.run(App.class,args);
    }
}

我认为该错误可能是由于本地数据流服务器和 Spring Boot 之间的版本兼容性问题,但我无法找到正确的版本。 我也在https://github.com/spring-cloud/spring-cloud-dataflow/releases中搜索过,但是这里没有给出spring-cloud-starter-dataflow-server-local。

请帮助我正确的版本矩阵。

【问题讨论】:

    标签: spring-boot spring-cloud spring-cloud-dataflow


    【解决方案1】:

    您正在使用 Spring Cloud Data Flow 版本 - Edgware.SR4。它与 Spring Boot 1.5.14 兼容。

    例如:Hoxton.SR8(spring cloud 版) 兼容2.3.3.RELEASE(spring boot) 参考https://github.com/spring-cloud/spring-cloud-dataflow/releases?after=v1.7.4.RELEASE

    你得到了上面的异常,因为你没有添加 spring cloud dependencyMangement 块。但是你需要一个spring cloud的依赖管理块(这个块是spring cloud技术所必需的——一堆技术,比如spring cloud ribbon、spring cloud zuul等等)。

    也添加这个,

    <properties>
            <java.version>8</java.version>
            <spring-cloud.version>Hoxton.SR8</spring-cloud.version>
    </properties>
    
    <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>${spring-cloud.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
    </dependencyManagement>
    

    我建议您使用start.spring.io创建一个spring boot项目,添加所需的依赖项,选择您的spring boot所需版本,它提供spring cloud兼容版本,而不是您自己手动选择。

    注意: 您可以通过向下滚动并使用下一步按钮在同一页面中检查所有兼容版本(spring boot 和 spring cloud 数据流)

    【讨论】:

      猜你喜欢
      • 2021-09-11
      • 2015-06-09
      • 2023-04-05
      • 2022-01-05
      • 2022-12-04
      • 2021-12-16
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      相关资源
      最近更新 更多