• Springboot | Failed to execute goal org.springframework.boot:spring-boot-maven-plugin


    案例


    今天搭建spring boot 环境时,使用mvn install ,出现Failed to execute goal org.springframework.boot:spring-boot-maven-plugin异常,经过多次构建都无效,配置和异常信息如下:
    <?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.evanshare</groupId>
      <artifactId>springBootDemo</artifactId>
      <packaging>war</packaging>
      <version>1.0-SNAPSHOT</version>
      <!-- Inherit defaults from Spring Boot -->
      <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version>
      </parent>
    
      <!-- Add typical dependencies for a web application -->
      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
      </dependencies>
    
      <!-- Package as an executable jar -->
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    
    </project>

    异常信息:
    "D:Program FilesJavajdk1.8.0_66injava" -Dmaven.multiModuleProjectDirectory=D:RepositoryGitEshare_practicesSpringBootDemo -DarchetypeCatalog=internal -Dmaven.home=D:Mavenapache-maven-3.3.3-binapache-maven-3.3.3 -Dclassworlds.conf=D:Mavenapache-maven-3.3.3-binapache-maven-3.3.3inm2.conf -Didea.launcher.port=7535 "-Didea.launcher.bin.path=D:Program Files (x86)JetBrainsIntelliJ IDEA 2016.1.3in" -Dfile.encoding=UTF-8 -classpath "D:Mavenapache-maven-3.3.3-binapache-maven-3.3.3ootplexus-classworlds-2.5.2.jar;D:Program Files (x86)JetBrainsIntelliJ IDEA 2016.1.3libidea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=2016.1.3 -s D:Mavenapache-maven-3.3.3-binapache-maven-3.3.3confsettings.xml -Dmaven.repo.local=D:Users10856214.m2
    epository install
    [WARNING] 
    [WARNING] Some problems were encountered while building the effective settings
    [WARNING] Unrecognised tag: 'repository' (position: START_TAG seen ...<profile>
    	<repository>... @281:14)  @ D:Mavenapache-maven-3.3.3-binapache-maven-3.3.3confsettings.xml, line 281, column 14
    [WARNING] Unrecognised tag: 'repository' (position: START_TAG seen ...<profile>
    	<repository>... @281:14)  @ D:Mavenapache-maven-3.3.3-binapache-maven-3.3.3confsettings.xml, line 281, column 14
    [WARNING] 
    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building springBootDemo 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ springBootDemo ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 0 resource
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springBootDemo ---
    [INFO] No sources to compile
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ springBootDemo ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory D:RepositoryGitEshare_practicesSpringBootDemosrc	est
    esources
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ springBootDemo ---
    [INFO] No sources to compile
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ springBootDemo ---
    [INFO] No tests to run.
    [INFO] 
    [INFO] --- maven-war-plugin:2.6:war (default-war) @ springBootDemo ---
    [INFO] Packaging webapp
    [INFO] Assembling webapp [springBootDemo] in [D:RepositoryGitEshare_practicesSpringBootDemo	argetspringBootDemo-1.0-SNAPSHOT]
    [INFO] Processing war project
    [INFO] Copying webapp resources [D:RepositoryGitEshare_practicesSpringBootDemosrcmainwebapp]
    [INFO] Webapp assembled in [133 msecs]
    [INFO] Building war: D:RepositoryGitEshare_practicesSpringBootDemo	argetspringBootDemo-1.0-SNAPSHOT.war
    [INFO] 
    [INFO] --- spring-boot-maven-plugin:1.4.0.RELEASE:repackage (default) @ springBootDemo ---
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.576 s
    [INFO] Finished at: 2016-09-10T23:08:14+08:00
    [INFO] Final Memory: 20M/315M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage (default) on project springBootDemo: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to find main class -> [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/PluginExecutionException
    
    Process finished with exit code 1
    


    解决方案

    注意这句异常信息:
    Unable to find main class -> [Help 1]
    经过排查,原来是因为我在idea构建maven web项目时,没有加入java文件夹和spring boot的入口配置类

    1.在main目录下创建一个java目录,然后创建一个入口类


    2.点击Mvn clean 和Mvn install,此时可以在控制台看到构建成功的信息


  • 相关阅读:
    ImageView一例
    TextView之一:子类的常用属性
    TextView之二:常用属性
    Android中的消息机制:Handler消息传递机制
    关于LayoutParams
    LinearLayout的一些注意事项
    支付宝扫描二维码登录网站
    Cok
    Cok
    STM32的USART
  • 原文地址:https://www.cnblogs.com/evan-liang/p/12233951.html
Copyright © 2020-2023  润新知