Maven搭建MyEclipse10+Struts2.1+Spring3.3+Hibernate3.3全注解框架
<!-- 使用 annotation 自动注册bean,并检查@Controller, @Service, @Repository注解已被注入 --> <context:component-scan base-package="org.inscribe.farsighted" />
<!-- 配置事务管理 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean>
<!-- 配置注解实现管理事务(cglib:proxy-target-class="true") --> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
</beans>
3. hibernate.cfg.xml修改
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> <session-factory> <property name="dialect"> org.hibernate.dialect.MySQLDialect </property> <property name="connection.url"> jdbc:mysql://localhost:3306/test </property> <property name="ername">root</property> <property name="connection.password">admin</property> <property name="connection.driver_class"> com.mysql.jdbc.Driver </property> <property name="myeclipse.connection.profile">MYSQL</property> <!-- <mapping class="org.inscribe.farsighted.model.Student" /> --> <!-- Connection Pooling Info --> <property name="initialSize">5</property> <property name="maxActive">100</property> <property name="maxIdle">30</property> <property name="maxWait">500</property> <property name="defaultAutoCommit">false</property>