弄了半天  (好久哦)

首先 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. 记一次python编码错误

    摘要: 断断续续写python一段时间了,让我说python最令我头疼的问题,莫过于编码问题.最近做大论文,使用python再次出现编码报错.错误如下: "UnicodeEncodeErro ...

  2. 01 初识python

    python.exe -v / python3 -v安装python3时, 会得到一个 IDLE(提示符>>>), 简单, 有用, 包含语法编辑器(颜色可变), 调试工具, pyth ...

  3. js /jquery停止事件冒泡和阻止浏览器默认事件

    1>js阻止冒泡事件 var el = window.document.getElementById("a"); el.onclick = function (e) { // ...

  4. 本周psp(观众页面)

    个人项目PSP(观众页面) 计划 30min 估计要用多长时间 3d 开发 5h 需求分析 1h 生成设计文档 1h 设计复审 50min 代码规范 20min 具体设计 40min 具体编码 3h ...

  5. PHP 中 define() 和 const 定义常量时的区别

    自 PHP 5.3.0 起,有两种方式定义常量,使用 const 关键字或者 define() 函数:   1 2 const FOO = 'BAR'; define('FOO', 'BAR'); 这 ...

  6. TestNG BeforeClass BeforeMethod Test AfterClass AfterMethod

    http://topmanopensource.iteye.com/blog/1983729 1.TestNG测试注解和Junit注解的不同以及生命周期: TestNG测试的一个方法的生命周期: @B ...

  7. [HTML/HTML5]5 使用链接

    5.1  添加指向其它Web页面的链接 无论目标Web页面是否属于你网站的一部分,还是属于其它网站,都可以添加指向其它Web页面的链接.只需要用<a>就可以添加链接. <a href ...

  8. ActionBar compat 如何禁用ActionBar的显示/隐藏动画

    ActionBar compat 如何关闭ActionBar的显示隐藏动画 @Override public boolean onCreateOptionsMenu(Menu menu) { //消除 ...

  9. 解决因为使用了官方xbean-2.4.0.jar 的库造成的性能问题

    最近我们游戏经常收到玩家投诉卡进度条的问题.而且后台显示执行队列和CPU使用率异常高 根据调用的JDB分析出 使用xbean 时候会调用以下代码 在设置xmlobject 时候会有一个 GlobalL ...

  10. Joomla

    joomla Joomla实际有两个开源的东西: 1.Joomla内容管理系统即JoomlaCMS(Content Management System, CMS).它是网站的一个基础管理平台.几乎适合 ...