首页 > 解决方案 > Spring 应用程序未运行(使用 Maven)

问题描述

Maven 构建似乎不起作用。下载所有依赖项后,我尝试在 Eclipse IDE 上使用 Maven 运行。

我正在尝试使用这个 pom.xml 文件运行 Spring App。

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.github.brunolellis</groupId>
    <artifactId>springweb-sync-async</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <name>Spring Boot Web - Sync and Async calls</name>

    <parent>
        <groupId>io.spring.platform</groupId>
        <artifactId>platform-bom</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath />
    </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-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

我收到有关找不到 org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE 的类的错误,我已包含在我的 pom.xml 中,但我仍然收到此错误。

BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.083 s
[INFO] Finished at: 2018-06-05T13:11:49+05:30
[INFO] Final Memory: 29M/396M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE:repackage (default) on project springweb-sync-async: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE:repackage failed: A required class was missing while executing org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE:repackage: org/springframework/asm/ClassVisitor
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.springframework.boot:spring-boot-maven-plugin:1.3.3.RELEASE
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/E080978/.m2/org/springframework/boot/spring-boot-maven-plugin/1.3.3.RELEASE/spring-boot-maven-plugin-1.3.3.RELEASE.jar
[ERROR] urls[1] = file:/C:/Users/E080978/.m2/org/springframework/boot/spring-boot-loader-tools/1.3.3.RELEASE/spring-boot-loader-tools-1.3.3.RELEASE.jar
[ERROR] urls[2] = file:/C:/Users/E080978/.m2/org/springframework/spring-core/4.2.5.RELEASE/spring-core-4.2.5.RELEASE.jar
[ERROR] urls[3] = file:/C:/Users/E080978/.m2/commons-logging/commons-logging/1.2/commons-logging-1.2.jar
[ERROR] urls[4] = file:/C:/Users/E080978/.m2/org/apache/maven/maven-archiver/2.6/maven-archiver-2.6.jar
[ERROR] urls[5] = file:/C:/Users/E080978/.m2/org/apache/maven/shared/maven-shared-utils/0.7/maven-shared-utils-0.7.jar
[ERROR] urls[6] = file:/C:/Users/E080978/.m2/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[7] = file:/C:/Users/E080978/.m2/org/codehaus/plexus/plexus-interpolation/1.21/plexus-interpolation-1.21.jar
[ERROR] urls[8] = file:/C:/Users/E080978/.m2/org/eclipse/aether/aether-util/1.0.2.v20150114/aether-util-1.0.2.v20150114.jar
[ERROR] urls[9] = file:/C:/Users/E080978/.m2/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
[ERROR] urls[10] = file:/C:/Users/E080978/.m2/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
[ERROR] urls[11] = file:/C:/Users/E080978/.m2/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
[ERROR] urls[12] = file:/C:/Users/E080978/.m2/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[ERROR] urls[13] = file:/C:/Users/E080978/.m2/org/eclipse/sisu/org.eclipse.sisu.inject/0.0.0.M5/org.eclipse.sisu.inject-0.0.0.M5.jar
[ERROR] urls[14] = file:/C:/Users/E080978/.m2/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[15] = file:/C:/Users/E080978/.m2/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[16] = file:/C:/Users/E080978/.m2/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[17] = file:/C:/Users/E080978/.m2/org/apache/maven/shared/maven-common-artifact-filters/1.4/maven-common-artifact-filters-1.4.jar
[ERROR] urls[18] = file:/C:/Users/E080978/.m2/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4.jar
[ERROR] urls[19] = file:/C:/Users/E080978/.m2/log4j/log4j/1.2.17/log4j-1.2.17.jar
[ERROR] urls[20] = file:/C:/Users/E080978/.m2/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
[ERROR] urls[21] = file:/C:/Users/E080978/.m2/com/google/collections/google-collections/1.0/google-collections-1.0.jar
[ERROR] urls[22] = file:/C:/Users/E080978/.m2/junit/junit/4.12/junit-4.12.jar
[ERROR] urls[23] = file:/C:/Users/E080978/.m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
[ERROR] urls[24] = file:/C:/Users/E080978/.m2/org/codehaus/plexus/plexus-archiver/2.8.1/plexus-archiver-2.8.1.jar
[ERROR] urls[25] = file:/C:/Users/E080978/.m2/org/codehaus/plexus/plexus-io/2.3.2/plexus-io-2.3.2.jar
[ERROR] urls[26] = file:/C:/Users/E080978/.m2/org/apache/commons/commons-compress/1.9/commons-compress-1.9.jar
[ERROR] urls[27] = file:/C:/Users/E080978/.m2/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar
[ERROR] urls[28] = file:/C:/Users/E080978/.m2/org/apache/maven/plugins/maven-shade-plugin/2.2/maven-shade-plugin-2.2.jar
[ERROR] urls[29] = file:/C:/Users/E080978/.m2/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[30] = file:/C:/Users/E080978/.m2/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[31] = file:/C:/Users/E080978/.m2/asm/asm/3.3.1/asm-3.3.1.jar
[ERROR] urls[32] = file:/C:/Users/E080978/.m2/asm/asm-commons/3.3.1/asm-commons-3.3.1.jar
[ERROR] urls[33] = file:/C:/Users/E080978/.m2/asm/asm-tree/3.3.1/asm-tree-3.3.1.jar
[ERROR] urls[34] = file:/C:/Users/E080978/.m2/org/jdom/jdom/1.1/jdom-1.1.jar
[ERROR] urls[35] = file:/C:/Users/E080978/.m2/org/apache/maven/shared/maven-dependency-tree/2.1/maven-dependency-tree-2.1.jar
[ERROR] urls[36] = file:/C:/Users/E080978/.m2/org/vafer/jdependency/0.7/jdependency-0.7.jar
[ERROR] urls[37] = file:/C:/Users/E080978/.m2/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar
[ERROR] urls[38] = file:/C:/Users/E080978/.m2/asm/asm-analysis/3.2/asm-analysis-3.2.jar
[ERROR] urls[39] = file:/C:/Users/E080978/.m2/asm/asm-util/3.2/asm-util-3.2.jar
[ERROR] urls[40] = file:/C:/Users/E080978/.m2/com/google/guava/guava/18.0/guava-18.0.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------: org.springframework.asm.ClassVisitor
[ERROR] 

标签: javaspringmavenspring-boot

解决方案


将 pom.xml 中的父级更改为:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
</parent>

推荐阅读