1.eclipse添加maven插件
下载地址:http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/juno/SR2/eclipse-jee-juno-SR2-win32.zip&mirror_id=1142
Maven3.0.5版本下载地址:
http://maven.apache.org/download.cgi
2.maven配置文件pom.xml
<strong><dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<type>jar</type>
<scope>test</scope>
<optional>true</optional></strong>
<strong> </dependency></strong>
<strong></strong><pre style="white-space: pre-wrap; word-wrap: break-word; color: rgb(57, 57, 57); font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; padding: 0px; font-family: 'Courier New' !important;"><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><span style="white-space:pre"> </span><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">dependency</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">groupId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>org.springframework<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">groupId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">artifactId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>spring-web<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">artifactId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">version</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>4.0.2.RELEASE<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">version</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">dependency</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">dependency</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">groupId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>junit<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">groupId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">artifactId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>junit<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">artifactId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">version</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>3.8.1<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">version</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">scope</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>test<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">scope</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">dependency</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">dependency</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">groupId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>org.springframework<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">groupId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">artifactId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>spring-context<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">artifactId</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"><</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">version</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>4.0.2.RELEASE<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">version</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;"></</span><span style="margin: 0px; padding: 0px; color: rgb(128, 0, 0); line-height: 1.5 !important;">dependency</span><span style="margin: 0px; padding: 0px; color: rgb(0, 0, 255); line-height: 1.5 !important;">></span>
<strong><span style="white-space:pre"> </span></strong><pre class="brush:xml;toolbar: true; auto-links: false;" style="padding: 5px; margin-top: 10px; margin-bottom: 10px; margin-left: 20px; line-height: 18px; font-size: 9pt; font-family: 'Courier New', Arial; border-width: 1px 1px 1px 5px; border-style: solid; border-color: rgb(221, 221, 221) rgb(221, 221, 221) rgb(221, 221, 221) rgb(108, 226, 108); color: rgb(51, 51, 51); background: rgb(246, 246, 246);"><dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${org.hibernate-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${org.hibernate-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${org.hibernate-version}</version>
</dependency>
<strong> </dependencies></strong>
3.
sessionFactory
<!-- 配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:config/hibernate.cfg.xml</value>
</property>
<property name="<span style="color:#ff0000;">dataSource</span>" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.ys.entity</value>
</list>
</property>
</bean>