This article introduces a complete example of creating a maven project for eclipse, and I will share it with you. The details are as follows:
The requirements tables are the same as springmvc cases
Just use maven here
Note that all the following needs to be built in your eclipse, etc., have been integrated and configured maven. To put it bluntly, maven can be found when building a new project.
If not, maven needs to be installed
1. Create a new maven project. If it is not on it, please go to other to find it.
2. After entering the maven project, click next
Next after selecting webapp
Enter two id packages and do not write them. It is the default to create a new package for you. It doesn’t matter if you don’t write them.
A project with such a directory will be generated
2. Configure maven
First create a few new folders
2.1 Add Source folder
Need to add next
src/main/java
src/test/java
src/test/resources three folders
Right-click the project root directory and click New -> Source Folder.
Create these three folders. Note that it is not a normal Folder, but a Source Folder.
Add a right-click new sourceFolder to the project or file. Under normal circumstances, there is no problem.
If the following situation occurs, it actually exists, but we can't see it
Right-click the project properties
Just switch to this
After setting it up, I found
Java already exists
Continue to create new ones that are not yet available
It's like this after the new creation
2.2 Change the class path
Right-click the 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 folder and select the path.
src/main/java, src/main/resources, select target/classes;
src/test/java , src/test/resources, select target/test-classes;
Select Allow output folders for source folders. (If not selected)
Here you can also change the display order
You can also change jdk here
Right-click the property project Facets
If you want to switch to 3.0, you will find an error
This is because when a new project is built
Used maven-artchetype-webapp
Since this catalog is relatively old, the servlet used is still 2.3
<?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>
----------------------
org.eclipse.jdt.core.prefs
Modify to
--------
Modify to
Reopen the property project Facets and see that this place has been modified to 3.0; check tomcat
Project creation is completed
new server
After starting, see if there is any error, currently there is no
Run it, the test is fine, and the maven web project is created at this point
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.