Create a Maven parent-child project and import it into Eclipse


1. Install eclipse
2. Change Preferences
(1) General->Workspace, change the encoding to UTF-8;
(2) Modify the Java path to the path where jdk is located;
(3) Maven->Installation, add the Maven installation directory ;
(4) Maven–>User Setting, modify the Maven configuration file;
3. Create the parent project

mvn archetype:generate -DarchetypeCatalog=internal -DgroupId=com.alan.springmvc -DartifactId=alan-springmvc
What appears in the middle, directly Just go back.
After the creation is complete, modify the packaging content in pom.xml to pom.
4. Create a subproject

mvn archetype:generate -DarchetypeCatalog=internal -DgroupId=com.alan.springmvc.dao -DartifactId=alan-springmvc-dao -DarchetypeArtifactId=maven-archetype-quickstart -Dversion=1.0

mvn archetype:generate -DarchetypeCatalog=internal -DgroupId=com.alan.springmvc.service -DartifactId=alan-springmvc-service -DarchetypeArtifactId=maven-archetype-quickstart -Dversion=1.0

mvn archetype:generate -DarchetypeCatalog=internal -DgroupId=com .alan.springmvc.web -DartifactId=alan-springmvc-web -DarchetypeArtifactId=maven-archetype-webapp -Dversion=1.0
After the creation is complete, delete the groupId and version lines in the subproject pom.xml, so that the parent class can be directly inherited.
5. Compile the project into an eclipse project
mvn eclipse:eclipse -Dwtpversion=1.0
6. Import the project into eclipse
7. Modify the dependencies: service depends on dao, web depends on service

com.alan.springmvcalan-springmvc-dao${project.version}
Modify the pom.xml of the web
com.alan.springmvcalan-springmvc-service${project.version}
8. Add the servlet dependency

javax.servletjavax.servlet-api3.0.1provided to the parent project
9. Maven Install parent project
Right-click on the parent project and select Run As –> Maven Install, if the following information appears, it means success.
[code="prettyprint"][INFO] alan-springmvc ................................ .SUCCESS [ 0.181 s]
[INFO] alan-springmvc-dao ................................. SUCCESS [ 0.629 s]
[INFO] alan-springmvc-service ............................... SUCCESS [ 0.020 s]
[INFO] alan-springmvc -web Maven Webapp ............................... SUCCESS [ 0.238 s]
[INFO] ------------------ -------------------------------------------------- ----
[INFO] BUILD SUCCESS
10. Run to tomcat

11. Browser access
browser input address: http://localhost:8080/alan-springmvc-web/index.jsp, if it can be accessed normally, it means our The project was created successfully.
So far, the Maven parent-child project has been created and imported into Eclipse.

http://blog.csdn.net/tangtong1/article/details/51436205

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326925025&siteId=291194637