我有一个 Eclipse 项目,它引用了另一个项目。
我已将这个其他项目包含在“属性”->“Java 构建路径”和“属性”->“部署程序集”中,以便在 Eclipse 工作区中定义的服务器上进行部署。
此配置包括 WEB-INF/lib 目录中的外部项目的 jar。
现在我想使用(右键单击)“Run As”->“Maven install”命令生成一个 war 文件。
我在 pom 中添加了 maven-war-plugin 插件:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webappDirectory>${project.build.directory}/${project.artifactId}</webappDirectory>
<warName>${project.artifactId}_${noVer}</warName>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addClasspath>false</addClasspath>
</manifest>
<manifestEntries/>
<manifestFile/>
</archive>
</configuration>
</plugin>
是否可以将其他项目作为 jar(自动)包含在 war 中?
谢谢。
编辑
“其他项目”是同一工作区中的 Eclipse 项目。
实际上是一个maven jar项目。
如前所述,它包含在原始项目中。
我想知道的是:
有没有办法(插件、指令...)将这个 ECLIPSE 项目直接包含在原始项目的 pom 中?
类似的东西
<dependency>
<groupId>org.myproject</groupId>
<artifactId>other_eclipse_project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
然后在WEB-INF/lib中找到一个“other_eclipse_project.jar”
最佳答案
Ulrich的答案是正确的,但它只会将其他项目生成的jar添加到您的 war 中。如果您的其他项目依赖于其他 jar,它们将不会被包含在内。
我很想将另一个项目更改为 Maven 项目,并将其所有依赖项添加到其 pom 中,这样您将获得所有传递依赖项。
关于java - 在 Maven 生成的 war 中包含外部 Eclipse 项目作为 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38243004/