TransactionProxyFactoryBean 配置问题

<?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:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<context:annotation-config />
    <context:component-scan base-package="com.*" />

<bean id="sessionFactory"  
            class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
        <property name="configLocation" value="classpath:hibernate.cfg.xml" />  
        <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
    </bean>

<!-- 定义事务管理器(声明式的事务) -->  
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    
    <!-- 配置DAO -->
    <bean id="generatorDaoTarget" class="com.*.spring.dao.GeneratorDaoImpl">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    
    <bean id="generatorDao"  
        class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">  
        <!-- 配置事务管理器 -->  
        <property name="transactionManager"><ref bean="transactionManager" /></property>  
        <property name="target"><ref bean="generatorDaoTarget" /></property>  
        <property name="proxyInterfaces"><value>com.*.spring.dao.GeneratorDao</value></property>
        <!-- 配置事务属性 -->  
        <property name="transactionAttributes">  
            <props>  
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>  
        </property>  
    </bean>

<bean id="plantDaoTarget" class="com.*.spring.dao.PlantDaoImpl">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    
    <bean id="plantDao"  
        class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">  
           <!-- 配置事务管理器 -->  
        <property name="transactionManager"><ref bean="transactionManager" /></property>     
        <property name="target"><ref bean="plantDaoTarget" /></property> 
        <property name="proxyInterfaces"><value>com.*.spring.dao.PlantDao</value></property>           
        <!-- 配置事务属性 -->  
        <property name="transactionAttributes">  
            <props>  
                <prop key="*">PROPAGATION_REQUIRED</prop>
            </props>  
        </property>  
    </bean>
    
    <!-- 配置Service -->
    <bean id="plantGeneratorServiceTarget"  
        class="com.*.spring.service.PlantGeneratorServiceImpl">  
        <property name="plantDao">  
            <ref bean="plantDao" />  
        </property>  
        <property name="generatorDao">  
            <ref bean="generatorDao" />  
        </property>  
    </bean>        
    
    <bean id="plantGeneratorService"  
        class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">  
           <!-- 配置事务管理器 -->  
           <property name="transactionManager"><ref bean="transactionManager" /></property>     
        <property name="target"><ref bean="plantGeneratorServiceTarget" /></property>  
        <property name="proxyInterfaces"><value>com.*.spring.service.PlantGeneratorService</value></property>
        <!-- 配置事务属性 -->  
        <property name="transactionAttributes">  
            <props>  
                <prop key="*">PROPAGATION_REQUIRED</prop>  
            </props>  
        </property>  
    </bean>  
</beans>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- 各属性的配置-->
    <!-- 为true表示将Hibernate发送给数据库的sql显示出来 -->
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.hbm2ddl.auto">none</property>

<!-- SQL方言,这边设定的是MySQL -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <!--连接数据库的Driver-->
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <!--数据库连接url-->
    <property name="connection.url">jdbc:mysql://localhost:3306/test</property>

<!--用户名-->
    <property name="connection.username">root</property>
    <!--密码-->
    <property name="connection.password">123456</property>

<!-- 映射文件  -->
    <mapping class="com.*.spring.domain.Generator" />
    <mapping class="com.*.spring.domain.Plant" />
</session-factory>
</hibernate-configuration>

public interface GeneratorDao {

/**
     * 获取所有机组数据
     * @return
     */
    public List<Generator> listGenerators();
    
    /**
     * 保存机组数据
     * @param generator 机组数据
     */
    public void save(Generator generator);    
}

public class GeneratorDaoImpl extends HibernateDaoSupport implements GeneratorDao {
       
    @SuppressWarnings("unchecked")
    public List<Generator> listGenerators() {
        return this.getSession().createQuery("from Generator").list();
    }

public void save(Generator generator) {
        this.getSession().save(generator);    
    }
}

TransactionProxyFactoryBean 配置问题,布布扣,bubuko.com

时间: 2025-01-02 14:33:50

TransactionProxyFactoryBean 配置问题的相关文章

Struts2中使用Velocity模板时模板资源路径配置问题

在Struts2中使用Velocity模板时,如何以相对与Web工程的路径来配置模板资源文件路径这个问题网上千篇一律的来自Velocity官方文档.官方文档中指出如果是Web工程的话,模板的相对路径是工程根路径,今天在使用的时候有如下配置: Velocity.properties(默认在WEB-INF下): resource.loader =file, classclass.resource.loader.description = Velocity Classpath Resource Loa

spring配置中,properties文件以及xml文件配置问题

spring方便我们的项目快速搭建,功能强大,自然也会是体系复杂! 这里说下配置文件properties管理的问题. 一些不涉及到代码逻辑,仅仅只是配置数据,可以放在xxxx.properties文件里面,项目功能复杂的时候,往往properties文件很多,这时,就比较容易让人困惑,有些properties的文件内容总是加载不起来,应用启动时,就不断爆出错误,说某某参数加载失败,这个是什么原因呢? 其实,这个是spring配置的时候,org.springframework.beans.fact

HTTP 错误 404.3 – Not Found 由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。

今天,在vs2013中新建了一个placard.json文件,当我用jq读取它的时候,去提示404,直接在浏览器访问这个文件,提示: HTTP 错误 404.3 – Not Found 由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本,请添加处理程序.如果应下载文件,请添加 MIME 映射. 解决方案:进入IIS

由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。

错误: HTTP 错误 404.3 - Not Found 由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本,请添加处理程序.如果应下载文件,请添加 MIME 映射. windows 8系统,运行aspx页面出现上述错误信息,解决办法如下: iis7  :控制面板->打开或关闭windows功能->Internet信息服务->万维网服务->应用程序开发功能,勾选上“.net扩展性”和“ASP.NET”,保存后,重启IIS服务器即可. iis8:控制面板->打开或关闭w

hibernate初次配置问题

1.自动创建表结构 在hibernate.cfg.xml配置文件中修改 ? 1 <property name="hibernate.hbm2ddl.auto">update</property> 另外注意数据库方言配置,以mysql为例,hibernate提供好几种方言,注意匹配自己的mysql类型 ? 1 <property name="hibernate.dialect">org.hibernate.dialect.MySQL

windows7系统,JDK的环境变量配置问题

困扰了几天的问题,今天终于解决了!!!!!!!!!!此时此刻正在感动中!!!!!感谢网上的大神发的贴子,为了感谢他们,我把我的经验分享如下... 1.在官网上下一个最新版的JDK按提示安装,可已安装在任意盘下,没必要也不建议安装在C盘 2.进入环境变量设置的方法:"计算机"右键"属性"--"高级系统设置"--"高级"--"环境变量"打开环境变量设置窗口. 3.在下面的"系统环境变量"设置

HTTP 错误 404.3 - Not Found 由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。

解决问题:由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本,请添加处理程序.如果应下载文件,请添加 MIME 映射. WindowServer2012服务器,添加角色安装完.netframework和iis之后,运行aspx页面就报如下错误: HTTP 错误 404.3 - Not Found 由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本,请添加处理程序.如果应下载文件,请添加 MIME 映射. ?可能是缺少处理程序映射.默认情况下,静态文件处理程序将处理所有内容.?您要使用

解决ArcGIS中因SDE或数据库配置问题而导致服务荡掉的一种思路

1.背景 最近连续有两个项目现场出现了AGS服务荡掉的问题,一个是通州现场,一个是福州现场. 1.1通州现场的问题描述和解决思路 通州现场环境为ArcGIS9.2,使用IMS发布的地图服务,其问题表现为每隔两天左右,其地形图服务便会崩溃一次,重启地形图服务后地图可以正常显示. 因为IMS中地图的出图为动态出图,所以其出图时需要通过连接SDE,此问题的出现很可能是SDE中最大连接数的问题. 1.2福州现场的问题描述和解决思路 福州现场环境为ArcGIS10.0,使用的ArcGIS Server发布

linuxYUM源配置问题

以前在linux5版本的时候,总是认为YUM目录一定要配置到具体的目录,今天看了网上的资料才知道自己想太多,直接配置到ISO挂载目录就可以了. 具体配置: [rhel-source] name=Red Hat Enterprise Linux $releasever - $basearch - Source baseurl=file:///software/RHEL6U5/ enabled=1 gpgcheck=0 我这里是直接在系统里面创建文件夹,复制ISO文件进来的,也就相当于直接挂载了IS