弄了半天  (好久哦)

首先 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. SQL-Server使用点滴(二)

    二,对象的建立和使用 1,了解MSSql的[系统表] 对于SQL-Server中的所有对象,包括数据库,数据表,记录,字段,触发器,索引,数据类型等元素,均有对应的系统表记性记录.系统表是禁止直接删改 ...

  2. CentOS搭建NodeJS环境

    事件驱动,承受高并发……这些耀眼的光环,使前端开发者不能不去学习NodeJS. 今天就在开发环境把NodeJS搭建起来了. 1. 下载node wget http://nodejs.org/dist/ ...

  3. centos7 dokcer fastdfs

    docker run --name=fastdfstmp -tid centos /bin/bash docker cp /home/fastdfs fastdfstmp:/home docker e ...

  4. Java Web之JavaBean

    一.什么是javaBean javaBean是一个遵循特定写法的java类,通常具有如下的特点: 这个java类必须具有一个无参的构造函数. 属性必须私有化. 私有化的属性必须通过public类型的方 ...

  5. img的绝对路径转为相对路径

    $('#add_img').on('change', function(){ var objUrl = getObjectURL(this.files[0]) ; if (objUrl) { $(th ...

  6. 2014最后一天,好烦!这个问题从来没遇到过!网上查找了很多办法都没解决!并且no wifi 了!

    org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread ...

  7. Cordova+Ionic之坑

    命令:ionic platform add android 报错:Unable to start the daemon process…… 解决: 1)添加环境变量[_JAVA_OPTIONS],值: ...

  8. 【OS】分页和分段

    在网上找到了一个比较形象的比喻   打个比方,比如说你去听课,带了一个纸质笔记本做笔记.笔记本有100张纸,课程有语文.数学.英语三门,对于这个笔记本的使用,为了便于以后复习方便,你可以有两种选择. ...

  9. eclipse中的web环境配置

    一.tomcat的安装 直接官网下载,选择自动配置安装Exe文件. 测试: 1.启动安装目录下bin文件中的exe文件,观察是否安装完好.若出现打断文字黑框,则说明已经安装完好. 2.输入网址.htt ...

  10. CIDR风格

    CIDR地址中包含标准的32位IP地址和有关网络前缀位数的信息. eg: 地址:192.168.10.0/24,其中/24标示前面地址中的前24位代表网络部分,其余代表主机部分. 11000000 1 ...