弄了半天  (好久哦)

首先 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>
事务管理
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean> <tx:advice 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" pointcut-ref="perform"/>
</aop:config> --> <!--
导入类扫描的注解解析器和事务的注解解析器
-->
<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 注解写法的更多相关文章

  1. 常用的SSH注解标签

    常用的SSH注解标签 1.Spring的注解 关于配Bean用的        @Component        @Controller @Service @Repository        作用 ...

  2. ssh注解整合

    ssh注解整合 导入java包 配置struts2环境 1. 创建struts.xml配置文件 <?xml version="1.0" encoding="UTF- ...

  3. 详解SSH注解配置,bean注解、事物注解等

    使用过SSH注解的屌丝们都知道,要想使用注解需要在applicationContext.xml配置文件里面开启注解配置,开启方式如下:1.头部声明需加入xmlns:context="http ...

  4. aop注解 自定义切面的注解写法

    spring.xml中 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="h ...

  5. ssh注解开发

    引入需要的jar包 @Entity public class Teacher { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) priva ...

  6. ssh+注解开发 pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  7. Hibernate or JPA Annotation中BLOB、CLOB注解写法

    BLOB和CLOB都是大字段类型,BLOB是按二进制字节码来存储的,而CLOB是可以直接存储字符串的. 在hibernate or JPA Annotation中,实体BLOB.CLOB类型的注解与普 ...

  8. SSH注解方式与XML配置方式对照表

    一.Hibernate 1.一对多注解 2.单表注解 二.Struts2 Struts2注解 三.Spring 1.IOC注解 2.AOP注解

  9. ssh base 写法

    BaseDao package wl.oa.dao.base; public interface BaseDao<T>{ public void saveEntry(T t); } Bas ...

随机推荐

  1. Adding a Controller

    MVC stands for Model, View, Controller. MVC is a pattern for developing applications such that each ...

  2. SYSTick 定时器

        CM3 内核的处理器,内部包含了一个 SysTick 定时器,(SysTick 的时钟源自 HCLK 的 8 分频,8个系统时钟周期systick跳一个,即8*1/72M=1/9 us)Sys ...

  3. 启动tomcat部署项目时 ContainerBase.addChild: start:

    严重: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component ...

  4. 自己常用JS和JQ 函数

    //验证码函数 <button id="send">点击发送验证码</button> <script src="jquery.min.js& ...

  5. 一篇讲Java指令重排和内存可见性的好文

    在这里: http://tech.meituan.com/java-memory-reordering.html 指令重排和内存可见性(缓存不一致)是两个不同的问题. volatile关键字太强,即阻 ...

  6. 程序设计入门——C语言 第8周编程练习 1 单词长度(4分)

    第8周编程练习 依照学术诚信条款,我保证此作业是本人独立完成的. 温馨提示: 1.本次作业属于Online Judge题目,提交后由系统即时判分. 2.学生可以在作业截止时间之前不限次数提交答案,系统 ...

  7. webpack 学习笔记

    1.html-webpack-plugin 该插件主要作用是在release时,自动向index.html 文件中写入 <script>xx/xx/bundle.js</script ...

  8. 14TH本周工作量及进度统计

      14TH本周工作量及进度统计    本周psp:                    C(类别) C(内容) S(开始时间) ST(结束时间) I(中断时间) T(实际时间) 活动 本周会议 1 ...

  9. BZOJ2933:POI1999地图

    Description     一个人口统计办公室要绘制一张地图.由于技术的原因只能使用少量的颜色.两个有相同或相近人口的区域在地图应用相同的颜色.例如一种颜色k,则A(k) 是相应的数,则有: 在用 ...

  10. CSS 日常问题总结

    1.关于文本多余部分用省略号代替: http://www.cnblogs.com/hellman/p/5755376.html