我使用eclipse luna,我有2个maven项目:一个web应用程序和一个java库,它是web应用程序的一个依赖项。如何让m2e-WTP与maven建立jar依赖关系?
库的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>org.test</groupId>
<artifactId>library</artifactId>
<verson>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifestEntries>
<Dependencies>just a test</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
的webapp的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>org.test</groupId>
<artifactId>webapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.test</groupId>
<artifactId>library</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
现在,当我部署一个网络服务器(JBoss的)我的战争 '运行方式...' 时,生成war文件,并将库的jar嵌入到WEB-INF/lib下。 所以一切看起来都很好,除非它不是: 生成的jar不是由maven生成的,它会丢失在maven-jar-plugin
(在这种情况下为Dependencies: just a test
行)上设置的任何配置。
可能很明显,但如果我在库项目中使用'Run as Maven build',jar:jar
和package
目标会生成一个具有预期清单的jar。
这可能是微不足道的,但哪个版本在第一个pom中有jar?你确定它是0.0.1-SNAPSHOT? – Ria 2015-03-24 18:37:35
是的,以及我想清除POM内容,但它不是那么大,所以我现在复制粘贴整个文件内容。 – Ghetolay 2015-03-25 11:29:26
@Ghetolay我不清楚你的问题。你是说如果你运行POM文件为“Run as Maven build”,那么一切正常。但是,如果你在项目中运行它作为'运行为...'网络服务器,它就不好。 – 2015-03-26 10:38:42