我打包我的基于Maven的Spring应用程序:
mvn install-DskipTests -Peverything.
出现了一些奇怪的事情 . 在生成的jar的META-INF中,我找到了重复的pom.xml和pom.properties文件 . 有人可以解释一下吗?谢谢 .
这是提取的pom.xml
<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.abc.xyz</groupId>
<artifactId>migrate-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>migrate-app</name>
<url>http://maven.apache.org</url>
<dependencies>
..
</dependencies>
<profiles>
<profile>
<id>everything</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
命令输出:
mvn -version
Apache Maven 3.0.4(r1232337; 2012-01-17 15:44:56 0700)Maven home:C:\ apache-maven-3.0.4 \ bin .. Java版本:1.6.0_30,供应商:Sun Microsystems Inc .Java home:C:\ Program Files(x86)\ Java \ jdk1.6.0_30 \ jre默认语言环境:en_US,平台编码:Cp1252操作系统名称:“windows 7”,版本:“6.1”,arch:“x86”,家庭:“窗户”
5 回答
加
到你的pom.xml
看起来这是由Eclipse中的冲突引起的一个常见问题,尤其是m2e-wtp集成 .
有些人表示可以通过在要运行的目标列表中包含clean来修复它,例如
mvn clean package
.还要尝试更新m2e安装,并确保没有安装m2e或m2eclipse(pre-Indigo版本)的多个版本 .
一些针对此问题的其他人的引用:
http://dev.eclipse.org/mhonarc/lists/m2e-users/msg01995.html
https://issues.sonatype.org/browse/MECLIPSEWTP-209
https://issuetracker.springsource.com/browse/STS-2349
https://github.com/sonatype/m2eclipse-extras/issues/9
我知道这个问题有点陈旧,但我想我会就这个问题分享一些不为人知的信息 . 我遇到了同样的问题,我发现当我打开Eclipse并打开Eclipse时,我的工作区首选项设置为使用本机挂钩或轮询刷新工作区,额外的pom.xml和pom.properties文件由eclipse添加!关闭eclipse或删除刷新工作区选项为我解决了问题 . 这是一个很难追查的人,所以希望其他人也能从中受益 .
跟进@ Dan的工作:
我尝试了你的解决方案,它似乎工作 - 乍一看 . 然而,它只是推迟了最终的失败 .
在任何时候刷新工作空间时,都会在/ classes目录中创建pom.xml和pom.properties文件 . 之后,任何后来的“包”目标都将包含.jar中的重复文件,从而打破以后的任何签名 .
如果轮询开启 - 您“快速失败” . 如果它关闭,您可以在将来的构建中随意失败 .
不确定你的意思是
duplicate
但maven创建的jar确实带有pom.xml
和pom.properties
在META-INF
文件夹中 . 请参阅maven入门指南的this section .