One, download and install Maven
http://maven.apache.org/download.cgi
After decompression. Configure MAVEN's directory to Maven_home and add the%maven_home%\bin directory to the path
Then in the input MVN--version see if MAVEN was installed successfully.
Second, install the Maven-eclipse plugin
Use link to install, first download plugin http://download.csdn.net/download/qq185501667/7076183
Then unzip him, then under the Eclipse installation directory, create a new folder named links (the name does not matter), and then create a new Maven.link file inside, write to: Path=e:/eclipseplugins/maven (Your plugin directory To restart Eclipse, if you see the Welcome page, the installation is successful.
Third, new MAVEN project
Create a new parent module first
Select Maven Project
Next, and then direct the next step, do not tick create simple project, then go to the Archetype page, and select the default Maven-archetype-quickstart directly. Finally, fill in the GroupID (fill in the workgroup ID, for example, Org.zyx) Artifactid (you can fill in the project name, such as MyApp). The name of the package will not be said.
and then complete. Then modify the Pom.xml file, because our goal is to create a modular Web application, our current new is the parent module, it does not need a real build, is responsible for the organization of the child module, so the packaging to modify
[HTML] view plain copy <span style= "FONT-SIZE:14PX;" ><packaging>pom</packaging></span>
Four, new entity
Right-click New on parent item, select Maven module, and the rest ibid.
Because this project uses annotations to configure the Hibernate entity, the dependent dependencies of the annotation package are added
Modify Pom.xml, add [HTML] view plain copy <span style= "FONT-SIZE:14PX;" > <dependencies> <dependency> <GROUPID>ORG.HIBERNATE.JAVAX.PERSISTENCE&L T;/groupid> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1 .0.0.final</version> </dependency> </dependencies></span>
So maven will help us import the relevant jar pack, and if we go inside the Class,maven will also automatically download the source code for us.
New entity classes below:
Create a new class in the Src/main/java directory [Java] view plain copy <span style= "FONT-SIZE:14PX;" >package com.zyx.model.entity; Import java.util.List; Import Javax.persistence.CascadeType; Import Javax.persistence.Column; Import javax.persistence.Entity; Import Javax.persistence.GeneratedValue; Import Javax.persistence.Id; Import Javax.persistence.OneToMany; Import javax.persistence.Table; @Entity @Table (name = "T_user") public class USER {private