弄了半天  (好久哦)

首先 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. eclipse最有用快捷键整理

    在网上搜eclipse快捷键,可以搜出一大堆,大多罗列了n多的快捷键,估计大部分人看了以后都会头大的,我也头大,不过我一一尝试了一遍,整理出了eclipse最常用最有用,写代码必须用到的一些快捷键,大 ...

  2. hrbust1841再就业(状态压缩dp)

    本人刚学压缩dp,只能对这些水题写题解 一方面对自己的理解有加深作用 另一方面希望和各位大牛交流交流..... 如果有对状态dp不太了解的童鞋可以参考入门知识:http://wenku.baidu.c ...

  3. 在ionic/cordova中使用极光推送插件(jpush)

    Stpe1:创建一个项目(此处使用的是tab类型的项目,创建方式可参照我前一篇如何离线创建Ionic1项目) Stpe2:修改项目信息 打开[config.xml]修改下图内容:

  4. Linux C相关基础

    系统求助 man 函数名 man 2 函数名    -    表示函数是系统调用函数 man 3 函数名    -    表示函数是C的库函数     eg:man fread     man 2 w ...

  5. c语言练习

    #include<stdio.h> struct student{ ]; int No; ]; int sum; }; int strcmp(char *s, char *t) { int ...

  6. NFC

    NFC手机是指带有NFC模块的手机.带有NFC模块的手机可以做很多相应的应用.NFC是Near Field Communication缩写,即近距离无线通讯技术.在13.56MHz频率运行于20厘米距 ...

  7. HTML5 中的Nav元素详解

    什么是Nav元素 Nav元素可以用作页面导航的链接组,在导航链接组里面有很多的链接,点击每个链接可以链接到其他页面或者当前页面的其他部分,并不是所有的链接组都要被放在nav元素里面,我们只需要把最主要 ...

  8. VS后台程序无法调用App_Code里的公共类解决方案

    在Web应用程序中不能通过右键项目-〉”添加“-〉”添加ASP.NET文件夹“方式添加 .因为Web应用程序中App_Code就不存在 .不过可以通过手动的方式创建,添加一个文件夹命名为App_Cod ...

  9. git 使用 总结

    比较好的教程 http://backlogtool.com/git-guide/cn/intro/intro1_2.html 1.git流程图 2.git 新建仓库 git init git clon ...

  10. 《Spark MLlib机器学习实践》内容简介、目录

      http://product.dangdang.com/23829918.html Spark作为新兴的.应用范围最为广泛的大数据处理开源框架引起了广泛的关注,它吸引了大量程序设计和开发人员进行相 ...