我使用事务管理和 AOP 如下:
<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 内容更改如下:
<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">
春天的版本是:3.0.5.RELEASE