Kir*_*han 5 java maven-3 maven
我正在尝试基于Oracle Tutorial的Simple Java Web Start项目.我正在使用maven将其打包为webapp并将其部署到应用程序服务器.完整的源代码可在此处获得
https://github.com/KiranMohan/dynamic-tree-javaws-sample-project
maven项目结构就像
parent
|--lib
|--webapp
Run Code Online (Sandbox Code Playgroud)
webapp模块是一个maven war模块.需要在webapp.war的根目录下打包lib.jar.不在WEB-INF/lib下.
如何在maven中实现这一目标?
我发现正确的方法是使用maven-dependency-plugin.由于"lib.jar"未在"webapp"模块的编译阶段使用,因此它只是一个包时间依赖项.使用maven-dependency-plugin,我可以在准备包阶段将lib.jar复制到任何所需的目录.然后,maven-war包将包含.war包中的lib.jar.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>[ group id ]</groupId>
<artifactId>[artifact id]</artifactId>
<version>[ version ]</version>
<outputDirectory>${project.build.directory}/${project.artifactId}</outputDirectory>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
更新:
有一个webstart-maven-plugin可以更好地打包javaws应用程序.有关
详细信息,请参阅我的示例项目
https://github.com/KiranMohan/dynamic-tree-javaws-sample-project