I have a very simple WAR project and I want to include a directory named META-INF
at the top of the classes output folder where all the compiled Java classes are.
I'm using Maven, but it seems that by default Maven won't include anything that is not a Java class. So it ignores my META-INF
directory that is sitting at the top of the src
directory.
The META-INF
directory contains a file named persistence.xml
. Any quick pointers on how to instruct Maven to put this directory and file into the output folder?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Put this into pom.xml:
In general, for a Java-based Maven project, non-source files should go in the
src/main/resources
sub-directory of the project. The contents of thatresources
directory are copied to the output directory (by default,target/classes
) during the process-resources phase of the build.For Maven WAR projects, it is slightly more complicated: there is also the
src/main/webapp
directory, wherein Maven expects to findWEB-INF/web.xml
. To build your WAR file, that file must exist; otherwise, you'll see an error message like this:As the
WEB-INF
directory must exist undersrc/main/webapp
, I'd recommend avoiding defining it again insrc/main/resources
. Although this is perfectly valid and the contents of the two directories will be merged, it can get confusing if a file is defined in both. The contents ofsrc/main/resources
will take precedence as they are copied over the top of the contents fromsrc/main/webapp
.Give the below entry in POM.xml
Maven wants this type of information in the resources folder. See here for more information.
For specifying additional resource directories, see here.
I'll indirectly answer your question by saying that if you've already made the jump to Maven2 I'd definitely recommend using the Archetype Plugin. Using the webapp archetype will ensure you end up with a canonical directory structure. Anyone else looking at your source will immediiately know where everything is and there won't be any question as to where your files go.