
<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- 使用annotation定义数据库事务,这样可以在类或方法中直接使用@Transactional注解来声明事务 -->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
2.使用事务管理器来管理
<?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:jee="http://www.springframework.org/schema/jee"
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-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<aop:config>
<!-- 切入点指明了在执行com.zxt.service包中的所有方法时产生事务拦截 *** 作 -->
<aop:pointcut id="daoMethods"
expression="execution(* com.zxt.service.*.*(..))" />
<!-- 定义了将采用何种拦截 *** 作,这里引用到 txAdvice -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="daoMethods" />
</aop:config>
<!-- 事务通知 *** 作,使用的事务管理器引用自transactionManager -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 指定哪些方法需要加入事务 -->
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<!-- read-only="true":其余方法只读格式,加强其安全性 -->
<tx:method name="*" read-only="true" propagation="NOT_SUPPORTED" />
</tx:attributes>
</tx:advice>
</beans>
配置Service层中的哪些方法需要使用到事务,一般开发使用组的形式,即如下
表示该方法配置的事务
表示该类下所有的方法都是用该事务(与方法不冲突)
你好,非常高兴为你解答:在服务器上启用事务记录可以使系统捕获数据库的改变并将它们写入到事务记录中,这样当系统或介质出问题时您可以使用事务记录和第三方的备份软件来恢复数据库。下面就介绍如何配置事务记录(transaction log)。
1、确保被记录的所有数据库都在Domino数据目录或其子目录下
2、启动Administrator软件,点击"配置"标签
3、在"使用目录"域,选择该服务器的Domino目录
4、选择"服务器"视图下的"当前服务器文档"子视图,打开并编辑服务器文档
5、点击"事务记录"标签,完成以下域:
事务记录:启用,缺省是禁用
日志路径:填写相对于Domino数据目录的路径,例如(logdir)
使用日志设备上的所有可用空间:是否使用设备上所有可用的空间来进行事务记录
如果选择"否",则在下面的域中填写"最大日志空间"最大日志空间:事务记录所使用的最大尺寸,以MB为单位.缺省是192MB,最大是4096MB.根据您分配的最大日志空间,Domino生成最少3个,最多64个日志文件
自动修正已损坏数据库:
选择"启用":如果数据库损坏,并且Domino不能使用事务记录来恢复它,则Domino运行Fixup任务,分配新的DBIID,并通知管理员做新的备份
选择"禁用":Domino不自动运行Fixup任务,而是通知管理员对损坏的数据库手工运行Fixup任务(带-J参数).如果事务记录在正常工作,不需要启用该选项.运行时间/重新启动惯用选项:该域控制Domino以什么频率在事务记录中记录恢复断点,它影响服务器的性能。
标准:(缺省并推荐)经常记录断点
运行时间:记录较少的断点,它要求较少的系统资源,会提高服务器的运行性能
重启恢复时间:记录很多的断点,它会减少服务器重新启动的恢复时间
记录样式:
循环:(缺省)连续地重用日志文件,覆盖旧的日志文件,您只能恢复记录在事务记录中的日志文件。
归档:(推荐)只有当日志文件被归档后,才重用日志文件.当日志文件处于不激活状态时(即不包含重新启动时的必要的恢复信息时),可以将它归档.使用
第三方的备份程序来拷贝和归档当前的日志.当Domino使用当前的文件再启动时,它增加日志文件的名称. 如果所有日志文件是不激活的并且没有被
归档,Domino创建附加的日志文件。
重新启动服务器生效。
当您重新启动服务器后,您将在控制台上看到如下信息:
Recovery Manager: Assigning new DBIID for f:\Lotus\Domino\Data\databasename.nsf (need new backup for media recovery).
它将为每一个需要事务记录的数据库分配一个新的DBIID.
另外,Domino创建事务日志文件(.TXN文件)和控制文件(nlogctrl.lfh),并将它们放在\logdir目录下。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)