简体   繁体   English

Maven-战争中的罐子

[英]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. 我正在将一个旧的Ant构建转换为Maven项目,并且我想维护他们使用Ant创建的最终War文件的确切结构。 Here is the desired structure of the War file. 这是War文件的所需结构。

在此处输入图片说明

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. 我在弄清楚如何创建一个jar.example.java并将其放入一个名为applet的文件夹时遇到了麻烦,该文件夹与web文件夹中的其他文件夹处于同一级别。 I can restructure the project any way I like but I have to keep the resulting war file's structure the same. 我可以按照自己喜欢的任何方式重组项目,但必须保持生成的war文件的结构不变。 So how do you create a jar file and a war file and place the jar file inside the war? 那么,如何创建jar文件和war文件并将jar文件放入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. 注意:我一直在尝试使用此示例,即如何从打包为war的项目部分中创建jar ,但是结构是如此不同,以至于无法使其完全符合我的要求后。

PS I'm also curious as to why they set up their Ant build this way to begin with. PS我也很好奇他们为什么以这种方式建立自己的Ant构建。 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. 我的意思是,将类包装在罐子中并放在applet文件夹中,而不是仅仅将它们放在战争中的传统位置(这将在WEB-INF / classes / java / com / example下),这有什么意义? /*。类。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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