After a long time (long time)
First applicationContext-db.xml
<? XML version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: AOP = "http://www.springframework.org/schema/aop" xmlns: Tx = "http://www.springframework.org/schema/tx" xmlns: context = "http://www.springframework.org/schema/context" xsi: schemalocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans -2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd "> <! -- <Bean id = "sessionfactory" class = "org. springframework. orm. hibernate3.localsessionfactorybean "> <property name =" configlocation "> <value> classpath: hibernate/hibernate. cfg. XML </value> </property> </bean> transaction management <bean id = "transactionmanager" class = "org. springframework. orm. hibernate3.hibernatetransactionmanager "> <property name =" sessionfactory "> <ref bean =" sessionfactory "/> </property> </bean> <TX: advic E transaction-Manager = "transactionmanager" id = "TX"> <TX: Attributes> <TX: method Name = "Save *" Read-Only = "false"/> <TX: method name = "Update *" Read-Only = "false"/> <TX: method Name = "delete *" Read-Only = "false"/> <TX: method name = "*" Read-Only = "true"/> </TX: attributes> </TX: Advice> <AOP: config> <AOP: pointcut expression = "execution (* WL. oa. service. impl. *. *(..)) "id =" perform "/> <AOP: Advisor advice-ref =" TX "Poi Ntcut-ref = "perform"/> </AOP: config> --> <! -- Import annotation Parser for class scanning and transaction annotation parser --> <context: component-scan base-package = "WL. OA "> </Context: component-scan> <TX: annotation-driven transaction-Manager =" transactionmanager "/> <bean id =" transactionmanager "class =" org. springframework. orm. hibernate3.hibernatetransactionmanager "> <property name =" sessionfactory "> <ref bean =" sessionfactory "/> </property> </bean> <bean id =" sessionfactory "class =" org. springframework. orm. hibernate3.localsessionfactorybean "> <property name =" configlocation "> <value> classpath: hibernate/hibernate. cfg. XML </value> </property> </bean> <bean id = "hibernatetemplate" class = "org. springframework. orm. hibernate3.hibernatetemplate "> <property name =" sessionfactory "> <ref bean =" sessionfactory "/> </property> </bean> </beans>
package wl.oa.dao;import wl.oa.dao.base.BaseDao;import wl.oa.domain.Person;public interface PersonDao<T> extends BaseDao<T>{ //public void savePerson(Person person);}
package wl.oa.dao.impl;import javax.annotation.Resource;import org.springframework.orm.hibernate3.HibernateTemplate;import org.springframework.stereotype.Repository;import wl.oa.dao.PersonDao;import wl.oa.dao.base.impl.BaseDaoImpl;import wl.oa.domain.Person;@Repository("personDao")public class PersonDaoImpl extends BaseDaoImpl<Person> implements PersonDao<Person>{// @Resource(name="hibernateTemplate")// private HibernateTemplate hibernateTemplate;// public void savePerson(Person person) {// // TODO Auto-generated method stub// this.hibernateTemplate.save(person);// }}
package wl.oa.service;import wl.oa.domain.Person;import wl.oa.service.base.BaseService;public interface PersonService<T> extends BaseService<T>{ //public void savePerson(Person person);}
package wl.oa.service.impl;import javax.annotation.Resource;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import wl.oa.dao.PersonDao;import wl.oa.domain.Person;import wl.oa.service.PersonService;import wl.oa.service.base.impl.BaseServiceImpl;@Service("personService")public class PersonServiceImpl extends BaseServiceImpl<Person> implements PersonService<Person>{ // @Resource(name="personDao")// PersonDao personDao; // public PersonDao getPersonDao() {// return personDao;// }//// public void setPersonDao(PersonDao personDao) {// this.personDao = personDao;// }// @Transactional(readOnly=false)// public void savePerson(Person person) {// // TODO Auto-generated method stub// this.personDao.savePerson(person);// }}
SSH annotation writing