Maven package错误:You have to use a classifier to attach supplemental artifacts to the project instead
来源:互联网 发布:凯瑟琳·哈尔西 知乎 编辑:程序博客网 时间:2024/06/07 00:04
我在pom.xml文件中添加了一个maven-jar-plugin的插件,目的是想多打一个jar包,如下:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> <executions> <execution> <id>service-jar</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classesDirectory>${project.build.directory}/webservice/</classesDirectory> </configuration> </execution> </executions></plugin>目的是将webservice目录打包成jar包,运行mvn package之后,却报错了:
...[INFO] --- maven-jar-plugin:3.0.2:jar (make-a-jar) @ deploy ---[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 6.035 s[INFO] Finished at: 2017-11-17T09:25:22+08:00[INFO] Final Memory: 18M/167M[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.0.2:jar (make-a-jar) on project deploy: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them. -> [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
例如当前工程的坐标:
<groupId>deploy</groupId><artifactId>deploy</artifactId><version>0.0.1-SNAPSHOT</version>那就是意味着打包之后的jar包名称为deploy-0.0.1-SNAPSHOT.jar,而在plugin中设置要打的jar包是额外的jar包,classifier的值设置为bak:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> <executions> <execution> <id>service-jar</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classifier>bak</classifier> <!-- 生成deploy-0.0.1-SNAPSHOT-bak.jar --> <classesDirectory>${project.build.directory}/webservice/</classesDirectory> </configuration> </execution> </executions></plugin>
总之,打出的jar包名称一定要区分,maven默认打多个jar包时不能覆盖掉原来的jar包,所以classifier就做了这个事情,可以从控制台打印的信息看到,maven执行了两次maven-jar-plugin的打包操作:
[INFO] [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ vbap3-webservice ---[WARNING] JAR will be empty - no content was marked for inclusion![INFO] Building jar: /deploy/target/deploy-0.0.1-SNAPSHOT.jar[INFO] [INFO] --- maven-jar-plugin:3.0.2:jar (vbap-jar) @ vbap3-webservice ---[INFO] Building jar: /deploy/target/deploy-0.0.1-SNAPSHOT-bak.jar[INFO]
如果是只想要使用plugin生成的jar包,那么可以直接把execution的id改为default-jar,因为默认本身会调用一个maven-jar-plugin并且执行一个default-jar的操作,这里如果命名了一个default-jar的操作,那么就会按照这个操作进行打包,但是这个时候不能添加classifier分类符,因为这时只有一个jar包。
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> <executions> <execution> <id>default-jar</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <!-- 没有classifier --> <classesDirectory>${project.build.directory}/webservice/</classesDirectory> </configuration> </execution> </executions></plugin>
阅读全文
0 0
- Maven package错误:You have to use a classifier to attach supplemental artifacts to the project instead
- 【Angular2】You have to be inside an angular-cli project in order to use the generate command
- 【angular】you have to be inside an Angular CLI project in order to use the serve command
- Query whether you have the access to a specific database
- How to resolve: You do not have a license to use this ActiveX control
- You need to install the perl-doc package to use this program.
- The goal you specified requires a project to execute but there is no POM in 错误
- You don’t have permission to save the file “project.xcworkspace” in the folder
- /Applications/Xcode.app/Contents/Developer/usr/bin/make package requires you to have a layout/ direc
- Project : error PRJ0050: Failed to register output. Please ensure you have the appropriate permissio
- 错误解决:Unable to add module to the current project as it is not of package
- How to use Deep Learning when you have Limited Data
- The project you are trying to remove is currently deployed to a running application server.解决方案
- MAVEN Error:HV000183: Unable to load 'javax.el.ExpressionFactory'. Check that you have the EL depend
- Is it possible to use a checkbox in a split button list instead of the gear icon?
- How to solve the problem : "You have been logged on with a temporary profile"
- Android编译错误:You have tried to change the API from what has been previously approved.
- Android编译错误:You have tried to change the API from what has been previously approved.
- js获取、比较浏览器名称和版本号的简便方法
- linux——显示磁盘容量命名df
- linux设备驱动之按键中断
- ubuntu16.4创建仓库认证registry
- Array.prototype.push.apply(a,b)与a.concat(b) 合并解析,array.filter实例(数组去重)
- Maven package错误:You have to use a classifier to attach supplemental artifacts to the project instead
- [LC]461. Hamming Distance
- 树莓派搭建Dlib库
- Google Guava 8-区间
- android animation
- Android 文件拷贝
- 运行hadoop程序时,有时候会报以下错误: org.apache.hadoop.dfs.SafeModeException: Cannot delete /user/hadoop/input. N
- [leetcode]database_SQL
- awesome图标库