Transferred from: https://www.cnblogs.com/noteless/p/5213075.html
Just use maven here
Note that all of the following needs to be built into your eclipse and so has the integrated configuration of MAVEN, which is plainly the time to find Maven when creating a new project.
If not, you need to install Maven
1. New MAVEN project, if not above, please go to other inside to find out
2. After entering the MAVEN project, click Next
Select WebApp After Next
Enter two ID package can not write, is it default to help you create a new bag, do not write it okay
Will generate a project of such a directory
2, configuring Maven
Create a few folders first
2.1 Adding the source folder
Next you need to add
Src/main/java
Src/test/java
Src/test/resources of three folders
Right-click on the project root to New, Source Folder,
Build these three folders. Note that you are not building a regular folder, but a Source folder.
Project or file plus right-click New Sourcefolder, normally there is no problem
If this happens, it really does exist, but we don't see it.
Project Right-click Property
It's good to switch to this.
After setting it up, I found
Java is already there.
Continue to create a few others that are not yet
It's like this after the new building.
2.2 Changing the class path
Right-click Project, Java Build Path, Source
There should be 4 folders below. Src/main/java,src/main/resources,src/test/java, Src/test/resources.
Double-click the output folder for each of the folders to select the path.
Src/main/java,src/main/resources, choose target/classes;
Src/test/java, src/test/resources, choose target/test-classes;
Select Allow output folders for source folders. (If not selected)
You can also change the display order here
You can also change the JDK here
Right-click Properties Project Facets
Want to switch to 3.0 to find an error
This is because when you create a new project,
With Maven-artchetype-webapp.
Because this catalog is older, the servlet used is still 2.3.
Modified into
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Archetype Created Web Application</display-name>
</web-app>
-------------
Under your new MAVEN project, find Maven's workspace.
Under the. Settings directory
Modified into
-------
Files under Project. Setting/org.eclipse.wst.common.project.facet.core.xml
Modified into
Reopen Properties Project Facets, see this place has been modified to 3.0; Tick on Tomcat
Project Engineering Creation Complete
New one server
After starting to see if there are any errors, there is no
Run, Test no problem---Browser input localhost:8080/project name return display Hello world!
This is where MAVEN Web project is created!
Eclipse creates a full example of a MAVEN project Dynamic Web project