Spring 应用程序未运行

问题描述 投票:0回答:1

我正在尝试运行一个简单的 Spring Boot 应用程序。它只有 web 作为依赖项。当我运行命令 clean install 时,它构建成功。但是 spring-boot 运行失败。我无法确定它是否存在依赖项冲突。我也运行了 mvn dependency:tree 命令,但我找不到任何冲突。 这是 mvn dependency:tree 的输出

          [INFO] Scanning for projects...
          [INFO]
          [INFO] ----------------------------------------------------------
          [INFO] Building demo 0.0.1-SNAPSHOT
          [INFO] ------------------------------------------------------------------------
          [INFO]
          [INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ demo ---
          [INFO] com.example:demo:jar:0.0.1-SNAPSHOT
          [INFO] \- org.springframework.boot:spring-boot-starter-web:jar:1.4.2.RELEASE:compile
          [INFO]    +- org.springframework.boot:spring-boot-starter:jar:1.4.2.RELEASE:compile
          [INFO]    |  +- org.springframework.boot:spring-boot:jar:1.4.2.RELEASE:compile
          [INFO]    |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.2.RELEASE:compile
          [INFO]    |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.4.2.RELEASE:compile
          [INFO]    |  |  +- ch.qos.logback:logback-classic:jar:1.1.7:compile
          [INFO]    |  |  |  +- ch.qos.logback:logback-core:jar:1.1.7:compile
          [INFO]    |  |  |  \- org.slf4j:slf4j-api:jar:1.7.21:compile
          [INFO]    |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.21:compile
          [INFO]    |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.21:compile
          [INFO]    |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.21:compile
          [INFO]    |  +- org.springframework:spring-core:jar:4.3.4.RELEASE:compile
          [INFO]    |  \- org.yaml:snakeyaml:jar:1.17:runtime
          [INFO]    +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.4.2.RELEASE:compile
          [INFO]    |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.6:compile
          [INFO]    |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.6:compile
          [INFO]    |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.6:compile
          [INFO]    +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
          [INFO]    |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
          [INFO]    |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
          [INFO]    |  \- com.fasterxml:classmate:jar:1.3.3:compile
          [INFO]    +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.4:compile
          [INFO]    |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.4:compile
          [INFO]    |  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.4:compile
          [INFO]    +- org.springframework:spring-web:jar:4.3.4.RELEASE:compile
          [INFO]    |  +- org.springframework:spring-aop:jar:4.3.4.RELEASE:compile
          [INFO]    |  +- org.springframework:spring-beans:jar:4.3.4.RELEASE:compile
          [INFO]    |  \- org.springframework:spring-context:jar:4.3.4.RELEASE:compile
          [INFO]    \- org.springframework:spring-webmvc:jar:4.3.4.RELEASE:compile
          [INFO]       \- org.springframework:spring-expression:jar:4.3.4.RELEASE:compile
          [INFO] ------------------------------------------------------------------------
          [INFO] BUILD SUCCESS
          [INFO] ------------------------------------------------------------------------
          [INFO] Total time: 2.990 s
          [INFO] Finished at: 2016-12-10T22:39:53+05:30
          [INFO] Final Memory: 20M/309M
          [INFO] ------------------------------------------------------------------------

请帮忙 这是控制台中的错误。

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 5.511 s
    [INFO] Finished at: 2016-12-10T22:24:00+05:30
    [INFO] Final Memory: 24M/227M
    [INFO] ------------------------------------------------------------------------
    [WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
    [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) on project demo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run failed: A required class was missing while executing org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run: org/springframework/asm/ClassVisitor
    [ERROR] -----------------------------------------------------
    [ERROR] realm =    plugin>org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE
    [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
    [ERROR] urls[0] = file:/C:/Users/i330945/.m2/repository/org/springframework/boot/spring-boot-maven-plugin/1.4.2.RELEASE/spring-boot-maven-plugin-1.4.2.RELEASE.jar
    [ERROR] urls[1] = file:/C:/Users/i330945/.m2/repository/org/springframework/boot/spring-boot-loader-tools/1.4.2.RELEASE/spring-boot-loader-tools-1.4.2.RELEASE.jar
    [ERROR] urls[2] = file:/C:/Users/i330945/.m2/repository/org/springframework/spring-core/4.3.4.RELEASE/spring-core-4.3.4.RELEASE.jar
    [ERROR] urls[3] = file:/C:/Users/i330945/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar
    [ERROR] urls[4] = file:/C:/Users/i330945/.m2/repository/org/apache/maven/maven-archiver/2.6/maven-archiver-2.6.jar
    [ERROR] urls[5] = file:/C:/Users/i330945/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.7/maven-shared-utils-0.7.jar
    [ERROR] urls[6] = file:/C:/Users/i330945/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
    [ERROR] urls[7] = file:/C:/Users/i330945/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.21/plexus-interpolation-1.21.jar
    [ERROR] urls[8] = file:/C:/Users/i330945/.m2/repository/org/eclipse/aether/aether-util/1.0.2.v20150114/aether-util-1.0.2.v20150114.jar
    [ERROR] urls[9] = file:/C:/Users/i330945/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
    [ERROR] urls[10] = file:/C:/Users/i330945/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
    [ERROR] urls[11] = file:/C:/Users/i330945/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
    [ERROR] urls[12] = file:/C:/Users/i330945/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
    [ERROR] urls[13] = file:/C:/Users/i330945/.m2/repository/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/i330945/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
    [ERROR] urls[15] = file:/C:/Users/i330945/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
    [ERROR] urls[16] = file:/C:/Users/i330945/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
    [ERROR] urls[17] = file:/C:/Users/i330945/.m2/repository/org/apache/maven/shared/maven-common-artifact-filters/1.4/maven-common-artifact-filters-1.4.jar
    [ERROR] urls[18] = file:/C:/Users/i330945/.m2/repository/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4.jar
    [ERROR] urls[19] = file:/C:/Users/i330945/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar
    [ERROR] urls[20] = file:/C:/Users/i330945/.m2/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
    [ERROR] urls[21] = file:/C:/Users/i330945/.m2/repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar
    [ERROR] urls[22] = file:/C:/Users/i330945/.m2/repository/junit/junit/4.12/junit-4.12.jar
    [ERROR] urls[23] = file:/C:/Users/i330945/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
    [ERROR] urls[24] = file:/C:/Users/i330945/.m2/repository/org/codehaus/plexus/plexus-archiver/2.8.1/plexus-archiver-2.8.1.jar
    [ERROR] urls[25] = file:/C:/Users/i330945/.m2/repository/org/codehaus/plexus/plexus-io/2.3.2/plexus-io-2.3.2.jar
    [ERROR] urls[26] = file:/C:/Users/i330945/.m2/repository/org/apache/commons/commons-compress/1.9/commons-compress-1.9.jar
    [ERROR] urls[27] = file:/C:/Users/i330945/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar
    [ERROR] urls[28] = file:/C:/Users/i330945/.m2/repository/org/apache/maven/plugins/maven-shade-plugin/2.2/maven-shade-plugin-2.2.jar
    [ERROR] urls[29] = file:/C:/Users/i330945/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
    [ERROR] urls[30] = file:/C:/Users/i330945/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
    [ERROR] urls[31] = file:/C:/Users/i330945/.m2/repository/asm/asm/3.3.1/asm-3.3.1.jar
    [ERROR] urls[32] = file:/C:/Users/i330945/.m2/repository/asm/asm-commons/3.3.1/asm-commons-3.3.1.jar
    [ERROR] urls[33] = file:/C:/Users/i330945/.m2/repository/asm/asm-tree/3.3.1/asm-tree-3.3.1.jar
    [ERROR] urls[34] = file:/C:/Users/i330945/.m2/repository/org/jdom/jdom/1.1/jdom-1.1.jar
    [ERROR] urls[35] = file:/C:/Users/i330945/.m2/repository/org/apache/maven/shared/maven-dependency-tree/2.1/maven-dependency-tree-2.1.jar
    [ERROR] urls[36] = file:/C:/Users/i330945/.m2/repository/org/vafer/jdependency/0.7/jdependency-0.7.jar
    [ERROR] urls[37] = file:/C:/Users/i330945/.m2/repository/commons-io/commons-io/1.3.2/commons-io-1.3.2.jar
    [ERROR] urls[38] = file:/C:/Users/i330945/.m2/repository/asm/asm-analysis/3.2/asm-analysis-3.2.jar
    [ERROR] urls[39] = file:/C:/Users/i330945/.m2/repository/asm/asm-util/3.2/asm-util-3.2.jar
    [ERROR] urls[40] = file:/C:/Users/i330945/.m2/repository/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] -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

这是我的 POM.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <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.example</groupId>
        <artifactId>demo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>

        <name>demo</name>
        <description>Demo project for Spring Boot</description>

        <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>1.4.2.RELEASE</version>
          <relativePath/> <!-- lookup parent from repository -->
        </parent>

        <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
          <java.version>1.8</java.version>
        </properties>

        <dependencies>  
          <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>      
          </dependency>  
        </dependencies>

      </project>
java spring maven spring-boot pom.xml
1个回答
0
投票

这是因为您缺少实际的

spring-boot
插件。将其添加到您的 pom.xml 中:

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

你应该很乐意和

mvn spring-boot:run

一起去
© www.soinside.com 2019 - 2024. All rights reserved.