Where should I have my Java source folder in the Maven web application architecture which results in a WAR?
Suggestions needed.
Now, once we execute the mvn install command, the WAR file will be generated inside the target folder. Using the mvn:war:exploded command, we can generate the exploded WAR as a directory inside the target directory.
web. xml file is always inside WEB-INF folder, by default Maven is expecting it in there and its the first location that is being searched for a web.
The basic structure that is standard for Maven project is the following.
src/main/java Application/Library sources
src/main/resources Application/Library resource
src/main/filters Resource filter files
src/main/assembly Assembly descriptors
src/main/config Configuration files
src/main/webapp Web application sources
src/test/java Test sources
src/test/resources Test resources
src/test/filters Test resource filter files
src/site Site
Following the Maven recommendations and normal behavior makes it easier for other people familiar with Maven to easy recognize and understand the structure.
Source/Read more
Maven web applications typically do not include java source code. The maven approach is to create a maven project for the "logic" of your web application (this will build into a jar) and create a second maven project for the webapp portion of your web application (this will build into a war). Then in the webapp portion, you introduce a dependency on the "logic" portion.
The end result is that when you build / test your logic jar (which contains servlets, etc), you will deploy that to your local repository and then build your war (which contains jsp pages, web.xml configs, etc).
Unless you explicitly specify it differently in your pom.xml
(productive) Java source files in a Maven project go to src/main/java
.
Java files always go in src/main/java and its advised to keep it that way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With