英文:
how to build war which has jars inside it in maven project
问题
I understand that you want to build a Maven project and generate a WAR file with specific configurations. Below is the translated content you requested:
我有一个 Maven 项目,其中包含 Java 源代码、配置文件和其他属性文件。我想要构建这个项目,生成一个 WAR 文件,其中所有的 Java 源代码将会放入 rtcc.jar 中,所有的配置文件将会放入 yamldef.jar 中。这两个 JAR 文件都应该放入 WAR 文件的 lib 文件夹中。因此,当我解压这个 WAR 文件时,应该有一个包含 rtcc.jar 和 yamldef.jar 的 lib 文件夹。请告诉我如何更新我的 pom.xml 文件。Java 源代码位于 src/main/java 文件夹中,配置文件位于 src/main/resources 文件夹中。请帮忙提供帮助。
英文:
I have maven project where i have java source code, configuration files and other properties files. i would like build this project to generate a war file where all java source code will go inside rtcc.jar. all configuration files will go into yamldef.jar and both these jars should go into lib folder of war file. so when i unzip the war file it should have lib folder which contains rtcc.jar and yamldef.jar. Please update how my pom.xml should look like. the java source code is there inside src/main/java folder. configuration files are there inside src/main/resources folder. Please help
答案1
得分: 0
你可以按照这里的说明,使用<archiveClasses>
将类放入单独的jar中:
https://maven.apache.org/plugins/maven-war-plugin/faq.html#attached
关于资源方面,我不清楚是否有类似的方法。
不过我要说的是:Maven和Ant非常不同。试图在Maven中重建Ant构建是不明智的。相反,要向前迈进,并接受结构的不同。团队会逐渐习惯的,你无需使Maven的行为像Ant一样弯曲。
英文:
You can put the classes into a separate jar by using <archiveClasses>
as decribed here:
https://maven.apache.org/plugins/maven-war-plugin/faq.html#attached
I don't know anything similar for the resources.
Let me say, though: Maven is very different from Ant. It is not sensible to try to rebuild Ant builds in Maven. Instead move forward and accept that structures are different. The team will get used to it and you don't need to bend Maven to behave like Ant.
专注分享java语言的经验与见解,让所有开发者获益!
评论