Maven webapp host jsps in / WEB-INF / jsp

I inherited a webapp built using the built-in NetBean ant.

All jsps are in:

WEB-INF/jsp 

And web.xml has hard links to / WEB -INF / jsp / somefile.jsp

How can I use the maven war plugin to host the JSP there, while maintaining consistency with the current structure?

My pom is currently reading:

 <warSourceDirectory>${basedir}/web/WEB-INF</warSourceDirectory> 
+7
java web-applications maven-2
source share
2 answers

What is the problem? Let's look at the standard structure of a war project:

 $ mvn archetype: create -DgroupId = com.mycompany.app \
 > -DartifactId = my-webapp -DarchetypepeArtifactId = maven-archetype-webapp
 ...
 $ tree my-webapp /
 my-webapp /
 | - pom.xml
 `- src
     `- main
         | - resources
         `- webapp
             | - WEB-INF
             |  `- web.xml
             `- index.jsp

 5 directories, 3 files 

No need to configure anything, just put the JSP under src/main/webapp/WEB-INF/jsp and there you go.

EDIT: I do not understand why you have the following line in the configuration of your maven-war-plugin:

 <warSourceDirectory>${basedir}/web/WEB-INF</warSourceDirectory> 

What is the expected behavior? Why aren't you using the default value of ${basedir}/src/main/webapp ?

+12
source share

Also note that everything in src / main / resources will be "on the classpath", i.e. everything will be copied to my-webapp / WEB-INF / classes when the war is built. So it's nice to host your configuration files, for example log4j.xml / logback.xml or Spring applicationContext.xml and Spring other configuration files, which can then be easily referenced with classpath: somefile.xml.

Which is also very nice, you can configure filters in maven so that it converts files from src / resources before placing them in a military file.

So, if you have any configuration files other than web.xml in src / main / webapp / WEB-INF, consider moving them to the src / main / resources directory.

+2
source share

All Articles