Eclipse version:
Eclipse Java EE IDE for Web Developers.
Version: Kepler Service Release 2
The above version of Eclipse already contains the basic maven plug-in. If the eclipse you are using does not have it, you can install it in Eclipse Help->Install New Software at the following address :
http://m2eclipse.sonatype.org/sites/m2e
Install WTP (Web Tools Project) plugin
Address : http://m2eclipse.sonatype.org/sites/m2e-extras option for Eclipse WTP
1. Create a Maven Project
New -> Maven Project
2. Select the project type as maven-archetype-webapp and click Next
3. Enter the Group ID and Artifact ID
Usually the Group ID is the name of the big project and the Artifact ID is the name of the sub-project
4. Turn the project into a Dynamic Web Project
right-click the project, Properties select Project Facets
At this point, it will prompt Cannot change version
Solution:
1) Switch the view to Navigator mode to modify the file in the figure
Modify org.eclipse.wst.common.component
to change project-version from 1.5.0 -> 1.7.0
修改org.eclipse.wst.common.project.facet.core.xml
facet="java" version="1.5" -> 1.7
facet="jst.web" version="2.3" -> 3.0
5. Modify the JRE System Library in the Java Build Path to 1.7
6. Check the Class output path
right click -> Java Build Path -> Source
The corresponding output class directory is as follows, if not corresponding, you need to specify
src/main/java -> target/classes;
src/main/resources -> target/classes;
src/test/java -> target/test-classes;
7. Set the Web Deployment Assembly
project -> right click -> Deployment Assembly
Delete the two items in the red box as shown in the figure
8. Add a dependency package
Double-click the pom.xml of the project and click Dependencies to add the following dependency packages . The
related dependency packages can be queried in the Maven central repository
: http://www.mvnrepository.com
Add the following dependencies
Several levels of Scope
1. compile, the default value, applies to all stages, will be released with the project.
2. provided, similar to compile, expects JDK, container or user to provide this dependency. Such as servlet.jar.
3. Runtime, only used at runtime, such as JDBC driver jstl, suitable for running and testing phases.
4. test, used only during testing, to compile and run the test code. Not released with the project.
5. system, similar to provided, needs to explicitly provide the jar containing the dependencies, Maven will not look it up in the Repository.
Attach a small example of SpringMVC
The command line can be built using maven eclipse:eclipse
URL: http://localhost:8080/SpringMVC/index.do