当前位置: 首页 > 知识库问答 >
问题:

Spring应用程序未运行

燕宜修
2023-03-14

我正在尝试运行一个简单的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
      <?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>

共有1个答案

澹台啸
2023-03-14

这是因为您缺少了实际的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

 类似资料:
  • 我是maven和Struts2的新手。当我尝试运行我的程序时,会出现以下错误:

  • 当我尝试运行此代码时,spring-boot应用程序会运行,但junit测试用例永远不会运行。但是如果我删除“@SpringBootTest(webEnvironment=webEnvironment.RANDOM_PORT)”,那么Junit测试会运行,但我的spring-boot应用程序不会运行。在我早期的项目中,这从来不是一个问题。

  • 我已经经历了一开始。Springio获得了添加了web和jpa依赖项的gradle示例应用程序,然后手动将Oracle依赖项添加到maven local,并在内部版本中添加了相同的依赖项。格雷德尔档案。我能够使用gradle任务构建应用程序,但是在运行时,我说我找不到Oracle驱动程序。 我已经验证了oracle jar文件的最终应用程序jar,发现它位于lib文件夹C:\Users\abcd\

  • 我有这个春靴应用程序。使用Quartz(一个功能丰富的开源作业调度库,几乎可以集成在任何Java应用程序中)在每月10日执行作业 在配置包中: 请参考一下,我有另一个类似的应用程序,没有,而且工作正常:

  • 我有一个spring boot的应用程序。我需要为一些测试设置一个cron作业。我如何设置一个cron作业来每15分钟调用一次应用程序?我使用从应用程序根目录运行到应用程序。

  • 当我发布windows窗体应用程序时,它在我开发它的机器上运行良好。但当我把它放在另一台笔记本电脑上就不工作了。双击.exe文件不会出错,也不会发生任何事情我的应用程序中有一个本地数据库。连接字符串为“data source=(LocalDB)\mssqllocaldb;attachdbfilename=datadirectory\database1.mdf;integrated security