People who have used Maven know that the directory structure of the MAVEN project is somewhat different from the traditional Dynamicweb project. Of course we do the best with Maven's specs, but what if you don't exactly follow Maven's specs and just need to use Maven to pack? In fact, it is simple, these can be changed by configuring the Pom file.
MAVEN Standard directory structure:
myproject/ |--pom.xml '--src |--main | | --java | | '--com | | '--mycompany | | -Resources | '--WebApp | | --Web-inf | | '--Web | '--index.jsp '--Test |--java | '--com | '--mycompany '--resources
Above is a standard MAVEN directory structure, and regular Web project JSP, JS, CSS and other files are put into the webcontent/webroot. In Maven, these files are placed under WebApp. So, if you use Maven directly to install the package, your page related files will not be packaged in, you will find that the war package is only src. class files and some configuration files. So how to include pages and other files in it?
Very simply, you just tell Maven where your JSP is located and configure it as follows:
<Build> <Finalname>ProjectName</Finalname> <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-war-plugin</Artifactid> <version>2.4</version> <Configuration> <!--Specify the location of the Web. xml File - <Webxml>Webcontent\web-inf\web.xml</Webxml> <!--specify where files such as JSPs are located - <warsourcedirectory>WebContent</warsourcedirectory> </Configuration> </plugin> </Plugins></Build>
OK plus the above configuration, and then execute the install command, to be packaged, you will find that the WebContent files are all included in the war package. You can now copy the beaten war package to Tomcat and run it.
You might think that you'll have to manually copy the package to Tomcat, and you'll have to do it manually every time you pack it up. The next article will be with you to learn how to package with Maven and automatically deploy to Tomcat. A blog to learn a little better, we do not worry Oh!
The tool of the Novice tutorial use (ii)--maven a Web project that packages a non-canonical directory structure