我正在尝试使用Maven将Web应用程序打包为可运行的JAR文件.该JAR-与依赖性组装照顾,包括所有的相关性,但我仍然需要包括的src/main/webapp的.
我设法使用自定义程序集将目录添加到我的JAR:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>webapp</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/webapp</directory>
<outputDirectory>/webapp</outputDirectory>
</fileSet>
</fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)
它确实有效,甚至可以将这个程序集与jar-with-dependencies一起使用.但是,最终的JAR包含webapp目录和所有依赖项,但不包含项目的类文件.我的装配显然正在移除它们.
我可以在程序集中保留我自己项目的类文件吗?或者是否有另一种方法将目录添加到JAR?
我的装配显然正在移除它们
我猜它是相反的,它不是添加它们.
您的类文件位于目标/类中,它们需要进入target/webapp/WEB-INF/classes.我猜你需要另一个这样的规则:
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/webapp/WEB-INF/classes</outputDirectory>
</fileSet>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2488 次 |
| 最近记录: |