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

ゞ 浴缸里的玫瑰 2022-09-25 13:21 305阅读 0赞

案例

今天搭建spring boot 环境时,使用mvn install ,出现Failed to execute goal org.springframework.boot:spring-boot-maven-plugin异常,经过多次构建都无效,配置和异常信息如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <groupId>com.evanshare</groupId>
  7. <artifactId>springBootDemo</artifactId>
  8. <packaging>war</packaging>
  9. <version>1.0-SNAPSHOT</version>
  10. <!-- Inherit defaults from Spring Boot -->
  11. <parent>
  12. <groupId>org.springframework.boot</groupId>
  13. <artifactId>spring-boot-starter-parent</artifactId>
  14. <version>1.4.0.RELEASE</version>
  15. </parent>
  16. <!-- Add typical dependencies for a web application -->
  17. <dependencies>
  18. <dependency>
  19. <groupId>org.springframework.boot</groupId>
  20. <artifactId>spring-boot-starter-web</artifactId>
  21. </dependency>
  22. </dependencies>
  23. <!-- Package as an executable jar -->
  24. <build>
  25. <plugins>
  26. <plugin>
  27. <groupId>org.springframework.boot</groupId>
  28. <artifactId>spring-boot-maven-plugin</artifactId>
  29. </plugin>
  30. </plugins>
  31. </build>
  32. </project>

异常信息:

  1. "D:\Program Files\Java\jdk1.8.0_66\bin\java" -Dmaven.multiModuleProjectDirectory=D:\Repository\Git\Eshare_practices\SpringBootDemo -DarchetypeCatalog=internal -Dmaven.home=D:\Maven\apache-maven-3.3.3-bin\apache-maven-3.3.3 -Dclassworlds.conf=D:\Maven\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin\m2.conf -Didea.launcher.port=7535 "-Didea.launcher.bin.path=D:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\bin" -Dfile.encoding=UTF-8 -classpath "D:\Maven\apache-maven-3.3.3-bin\apache-maven-3.3.3\boot\plexus-classworlds-2.5.2.jar;D:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=2016.1.3 -s D:\Maven\apache-maven-3.3.3-bin\apache-maven-3.3.3\conf\settings.xml -Dmaven.repo.local=D:\Users\10856214\.m2\repository install
  2. [WARNING]
  3. [WARNING] Some problems were encountered while building the effective settings
  4. [WARNING] Unrecognised tag: 'repository' (position: START_TAG seen ...<profile>\n\t<repository>... @281:14) @ D:\Maven\apache-maven-3.3.3-bin\apache-maven-3.3.3\conf\settings.xml, line 281, column 14
  5. [WARNING] Unrecognised tag: 'repository' (position: START_TAG seen ...<profile>\n\t<repository>... @281:14) @ D:\Maven\apache-maven-3.3.3-bin\apache-maven-3.3.3\conf\settings.xml, line 281, column 14
  6. [WARNING]
  7. [INFO] Scanning for projects...
  8. [INFO]
  9. [INFO] ------------------------------------------------------------------------
  10. [INFO] Building springBootDemo 1.0-SNAPSHOT
  11. [INFO] ------------------------------------------------------------------------
  12. [INFO]
  13. [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ springBootDemo ---
  14. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  15. [INFO] Copying 0 resource
  16. [INFO] Copying 0 resource
  17. [INFO]
  18. [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springBootDemo ---
  19. [INFO] No sources to compile
  20. [INFO]
  21. [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ springBootDemo ---
  22. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  23. [INFO] skip non existing resourceDirectory D:\Repository\Git\Eshare_practices\SpringBootDemo\src\test\resources
  24. [INFO]
  25. [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ springBootDemo ---
  26. [INFO] No sources to compile
  27. [INFO]
  28. [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ springBootDemo ---
  29. [INFO] No tests to run.
  30. [INFO]
  31. [INFO] --- maven-war-plugin:2.6:war (default-war) @ springBootDemo ---
  32. [INFO] Packaging webapp
  33. [INFO] Assembling webapp [springBootDemo] in [D:\Repository\Git\Eshare_practices\SpringBootDemo\target\springBootDemo-1.0-SNAPSHOT]
  34. [INFO] Processing war project
  35. [INFO] Copying webapp resources [D:\Repository\Git\Eshare_practices\SpringBootDemo\src\main\webapp]
  36. [INFO] Webapp assembled in [133 msecs]
  37. [INFO] Building war: D:\Repository\Git\Eshare_practices\SpringBootDemo\target\springBootDemo-1.0-SNAPSHOT.war
  38. [INFO]
  39. [INFO] --- spring-boot-maven-plugin:1.4.0.RELEASE:repackage (default) @ springBootDemo ---
  40. [INFO] ------------------------------------------------------------------------
  41. [INFO] BUILD FAILURE
  42. [INFO] ------------------------------------------------------------------------
  43. [INFO] Total time: 2.576 s
  44. [INFO] Finished at: 2016-09-10T23:08:14+08:00
  45. [INFO] Final Memory: 20M/315M
  46. [INFO] ------------------------------------------------------------------------
  47. [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]
  48. [ERROR]
  49. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  50. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  51. [ERROR]
  52. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  53. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
  54. Process finished with exit code 1

解决方案

注意这句异常信息:

  1. Unable to find main class -> [Help 1]

经过排查,原来是因为我在idea构建maven web项目时,没有加入java文件夹和spring boot的入口配置类

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

20160911003736587

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

20160911003926259

20160911004040091

发表评论

表情:
评论列表 (有 0 条评论,305人围观)

还没有评论,来说两句吧...

相关阅读