ssh 注解写法
弄了半天 (好久哦)
首先 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 注解写法的更多相关文章
- 常用的SSH注解标签
常用的SSH注解标签 1.Spring的注解 关于配Bean用的 @Component @Controller @Service @Repository 作用 ...
- ssh注解整合
ssh注解整合 导入java包 配置struts2环境 1. 创建struts.xml配置文件 <?xml version="1.0" encoding="UTF- ...
- 详解SSH注解配置,bean注解、事物注解等
使用过SSH注解的屌丝们都知道,要想使用注解需要在applicationContext.xml配置文件里面开启注解配置,开启方式如下:1.头部声明需加入xmlns:context="http ...
- aop注解 自定义切面的注解写法
spring.xml中 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="h ...
- ssh注解开发
引入需要的jar包 @Entity public class Teacher { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) priva ...
- ssh+注解开发 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- Hibernate or JPA Annotation中BLOB、CLOB注解写法
BLOB和CLOB都是大字段类型,BLOB是按二进制字节码来存储的,而CLOB是可以直接存储字符串的. 在hibernate or JPA Annotation中,实体BLOB.CLOB类型的注解与普 ...
- SSH注解方式与XML配置方式对照表
一.Hibernate 1.一对多注解 2.单表注解 二.Struts2 Struts2注解 三.Spring 1.IOC注解 2.AOP注解
- ssh base 写法
BaseDao package wl.oa.dao.base; public interface BaseDao<T>{ public void saveEntry(T t); } Bas ...
随机推荐
- 升级openssl环境至openssl-1.1.0c
升级openssl环境至openssl-1.1.0c1.查看源版本 [root@zj ~]# openssl version -aOpenSSL 1.0.1e-fips 11 Feb 2013 2.下 ...
- Arduino 极速入门系列 - 光控灯(2) - 关于开关,上拉、下拉电阻那些事
接上篇,这次继续讲解光控灯的另外两个组成部分 - 开关和光敏电阻,光控灯里面将会有自锁开关按钮和光敏电阻.这此主要给新玩电子的朋友解释一下开关按钮的做法. 开关按钮的引脚电平读取问题 - 新手专用 我 ...
- CSS选择器、标签,div的位置。
今天是休假,布置了一个作业,是利用CSS制作斯坦福大学官网.虽然是一个并不复杂的制作,却让我第一次体会到了想摔鼠标的感觉. 遇到了很多问题,却找不出自己到底是哪里出了问题,简简单单的一个logo.足足 ...
- 【问题】AndroidStudio导入项目一直卡在Building gradle project infod的最快速解决方案
原因 AndroidStudio导入项目一直卡在Building gradle project info的原因, 是因为导入的这个项目使用的gradle版本与本地已经拥有的gradle版本不一致,导致 ...
- 将JSON对象带有格式的写出到文件中
需求:将一个JSON对象写出到文件中,要求文件中的JSON数据带有简单的格式.代码的实现参考了Java算法中的栈处理括号匹配问题.好了,不多说了,下面是代码的实现. 代码: package gemu. ...
- YII 伪静态 IIS7 方法 web.config
YII 伪静态 IIS7 方法 web.config <?xml version="1.0" encoding="UTF-8"?> <conf ...
- maven中运行hibernate5的一些注意事项
问题1:Could not bind factory to JNDI hibernate.cfg.xml中<sessionFactory> 标签中的name="foo" ...
- 7 -- Spring的基本用法 -- 3...
7.3 Spring 的核心机制 : 依赖注入 Spring 框架的核心功能有两个. Spring容器作为超级大工厂,负责创建.管理所有的Java对象,这些Java对象被称为Bean. Spring容 ...
- yii2-basic后台管理功能开发之五:用户权限的控制
需求:后台有两种权限+管理员+用户 区别:可以访问的页面不同 解决方法:用户表添加role字段,使用到的是yii2 存取控制过滤器(ACF)方法. >1在web.php中配置授权的类,有两种,我 ...
- vertical-align
http://www.zhangxinxu.com/wordpress/2015/08/css-deep-understand-vertical-align-and-line-height/