How create file and put it in a war with Maven?

2019-08-29 13:36发布

问题:

How I can create file and put it in a war with Maven when building the war?

回答1:

Maven builds a war by executing the war goal of the maven-war plugin. Have a look at the configuration parameters of this goal at http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html.

Basically, warSourceDirectory (defaulting to ${basedir}/src/main/webapp) contains the files that go to the war, apart from your java code and resources. Fine tune with packagingIncludes/packagingExcludes. To include file(s) from another module, use overlay: http://maven.apache.org/plugins/maven-war-plugin/overlays.html.



回答2:

I'm assuming that you want a file that gets put on the classpath when your .jar or .war is assembled. You likely want to put it in src\main\resources.



回答3:

assuming your using eclipse+maven. put it Java resources>> package you want

then right click on the project maven>> update project. run the new pom.xml you'll get the new .war with everything in place.