1. Development environment
jdk1.7 tomcat7eclipse-jee-luna-R-win32 maven2.2.1
2. Construction steps
1. Click File->New->Other and select maven project
2. Select maven project, click Next, and then click next to enter the following interface
Select the last one as shown in the picture and click next
3. See the following interface
Enter Group Id and Artifact Id, click finish to complete the basic creation
4. The created project structure is shown in the figure (Java view)
If it is a Java EE view, the project structure you see does not look like this. You can change it to a Java view as follows
5. Right-click the project ->Build Path ->Configure Build Path... to enter the following interface
Click the mouse to select the red cross on the right, click remove to delete, click OK to save
6. Add source folder to create a standard maven web project structure
Right-click the project ->New->Source Folder->Fill in the folder name, as shown in the figure
Add src/main/java src/test/java src/test/resources in turn (src/main/resources already exists)
7. The new project structure is shown in the figure
8. Configure the output path
Right-click the project ->Build Path ->Configure Build Path... to enter the following interface
Select src/test/java, src/test/resources, click Edit, and change the output directory to: testDemo02/target/test-class (testDemo is my project name)
If Browse has this directory, select it; otherwise, manually enter testDemo02/target/test-class
8. Update related versions
Right-click Project->Properties->Project Facets, change jdk to the local installed version, mine is 1.7; Dynamic Web Modul cannot be changed here
Find the project location, change the org.eclipse.wst.common.project.facet.core.xml file under the .setting file, change the configuration of this line <installed facet="jst.web" version="2.3"/>, and change the version to 3.0
Update the project in eclipse, right-click Project->Properties->Project Facets again, and you will see that the Dynamic Web Modul has been changed to 3.0
9. Set up the deployment program collection
Right-click Project->properties->Deployment Assembly.
Delete two items of test, because test is used for testing and does not require deployment;
Add maven dependencies; Add->Java Build Path Entires->Maven Dependencies->Finish
The setup interface is as follows
10. Add relevant dependencies in pom.xml and update the maven project
11. Add Tomcat server in eclipse, add the project to the server, start tomcat, and then visit the project http://localhost:8080/testDemo02/ to see the familiar interface.
The above are the detailed steps for maven to build a Java ee project. I hope it will be helpful to everyone's learning.