maven打包错误: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project community: Input length = 1 -> [Help 1]
·
正常情况
[root@wu1 ~]# cd community # community是SpringBoot项目的文件夹
[root@wu1 community]# mvn clean package -Dmaven.test.skip=true # 用maven把项目编译并且打包,跳过测试,因为我们前面的测试类写的都不标准,最后单独讲的那个测试才是标准的测试。耗时较长。
[root@wu1 community]# cd target # 来到/root/community/target目录
[root@wu1 target]# ll # 看到ROOT.war文件
完整报错信息
[root@wu1 ~]# cd community
[root@wu1 community]# mvn clean package -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.nowcoder.community:community >------------------
[INFO] Building community 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ community ---
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ community ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 3 resources
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.375 s
[INFO] Finished at: 2021-05-18T13:30:27+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project community: Input length = 1 -> [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/MojoExecutionException
解决方法
报错原因:这可能是一个新的bug,在最近发布的spring-boot(和spring)中。
解决方法:
要绕过Spring Boot 2.4.x生成的错误,请执行以下操作:
在pom.xml里加入:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
形成下面这样。
<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--加上这个是为了防止出现maven打包错误-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version><!--亲测:3.1.0和2.4.3都可以。-->
</plugin>
</plugins>
</build>
打包成功
[root@wu1 ~]# cd community
[root@wu1 community]# mvn clean package -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.nowcoder.community:community >------------------
[INFO] Building community 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ community ---
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ community ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 49 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ community ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 70 source files to /root/community/target/classes
[INFO] /root/community/src/main/java/com/nowcoder/community/service/UserService.java: Some input files use unchecked or unsafe operations.
[INFO] /root/community/src/main/java/com/nowcoder/community/service/UserService.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ community ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ community ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ community ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:3.3.1:war (default-war) @ community ---
[INFO] Packaging webapp
[INFO] Assembling webapp [community] in [/root/community/target/ROOT]
[INFO] Processing war project
[INFO] Building war: /root/community/target/ROOT.war
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.3:repackage (repackage) @ community ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.930 s
[INFO] Finished at: 2021-05-18T21:33:40+08:00
[INFO] ------------------------------------------------------------------------
参考
更多推荐
已为社区贡献7条内容
所有评论(0)