maven package命名报错:You have to use a classifier to attach supplemental artifacts to the project inste

时间:2024-03-23 19:58:30

本地项目pom.xml文件添加了maven-jar-plugin插件,如下图!maven package命名报错:You have to use a classifier to attach supplemental artifacts to the project inste
然后执行maven package命名,结果BUILD FAILUREmaven package命名报错:You have to use a classifier to attach supplemental artifacts to the project inste
具体报错信息如下:Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar (make-a-jar) on project common: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them. -> [Help 1]

然后pom文件中加入一行代码maven package命名报错:You have to use a classifier to attach supplemental artifacts to the project inste
再次执行maven package,BUILD SUCCESS
maven package命名报错:You have to use a classifier to attach supplemental artifacts to the project inste
分析原因是因为:如果在plugin中添加maven-jar-plugin插件之后,maven会运行两次maven-jar-plugin插件,第一次运行是打包当前工程的jar,第二次运行是执行在plugin中设置的jar,这样的话会生成两个jar包,这里就要用到classifier这个属性了。classifier是用来标识不同的jar包的名称的一个分类符,这个属性的值会添加到工程jar包的名称后面。
转载来源:maven package报错