在spring中设置属性文件的超时<tx:method tag =“”

时间:2015-09-27 08:51:01

标签: java spring spring-aop spring-transactions spring-properties

=“”

我使用事务管理和AOP如下:

< / p>

<tx:advice id="tx.sys.advice" transaction-manager="sys.tx.mngr" >
    <tx:attributes>
        <tx:method name="suspendMember" read-only="false" propagation="REQUIRES_NEW" timeout="10"/>
    </tx:attributes>
</tx:advice>
<aop:config>
    <aop:pointcut id="domain.pointcut" expression="execution(* com.IUser.*(..))" />
    <aop:advisor advice-ref="tx.sys.advice" pointcut-ref="domain.pointcut" />

    <aop:advisor advice-ref="tx.sys.advice" pointcut-ref="domain.pointcut"  />
</aop:config>

我将超时设置为10但我想通过属性文件中的属性设置它。 我更改了我的xml contetnt如下:

<tx:method name="suspendMember" read-only="false" propagation="REQUIRES_NEW" timeout="${setting.timeout}"/>

如果发生上述变化,我会在运行时遇到错误,如下所示:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 20 in XML document from class path resource [context.xml] is invalid; 
nested exception is org.xml.sax.SAXParseException; 
lineNumber: 20; columnNumber: 116; 
cvc-datatype-valid.1.2.1: '${setting.timeout}' is not a valid value for integer'

修改

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

和spring的版本是:3.0.5.RELEASE

0 个答案:

没有答案