Maven project structure

The Maven project wizard creates src and target folders under the main project folder. As the name suggests, all source files go under src. However, Java package structure starts under the main folder. By convention, Maven expects Java source files under the java folder. Therefore, create a java folder under src/main. The Java package structure starts from the java folder, that is, src/main/java/<java-packages>. Web content such as HTML, JS, CSS, and JSP goes in the webapp folder under src/main. Compiled classes and other output files generated by the Maven build process are stored in the target folder:

Figure 2.35: Maven web application project structure

The source code for our login JSF page is the same as in the previous example of LoginJSFApp. Therefore, copy the packt folder from the src folder of that project to the src/main/java folder of this Maven project. This adds LoginBean.java to the project. Then, copy web.xml from the WEB-INF folder to the src/main/webapp/WEB-INF folder of this project. Copy index.xhtml and welcome.xhtml to the src/main/webapp folder:

Figure 2.36: Project structure after adding source files

No change is required in the source code. To run the application, right-click on index.xhtml and select Run As | Run on Server.

We will be using Maven for project management in the rest of this book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.97.75