简体   繁体   中英

Maven - Jar inside a War

I'm converting an old Ant build into a Maven project and I would like to maintain the exact structure of the resulting War file that they created using Ant. Here is the desired structure of the War file.

在此处输入图片说明

Here is the structure of the project before it is compiled and packaged.

在此处输入图片说明

I'm having trouble figuring out how to create a jar of example.java and place it into a folder called applet which is at the same level as the other folders from the web folder. I can restructure the project any way I like but I have to keep the resulting war file's structure the same. So how do you create a jar file and a war file and place the jar file inside the war?

Note: I've been trying to use this example here, How to create a jar from part of my project that is packaged as a war , but the structure is so different I'm having trouble getting it to be exactly what I'm after.

PS I'm also curious as to why they set up their Ant build this way to begin with. I mean, what is the point of having the classes packed up in a jar and placed inside the applet folder rather than just putting them in the traditional place inside a war which would would be under WEB-INF/classes/java/com/example/*.class.

最简单的方法是将example.java使用jar打包移到其自己的模块中(即子项目),然后在打包战争之前使用Maven依赖插件将该工件复制到/applet文件夹中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM