我可以将 @transactional 属性注入到注释中吗?
我有在 Spring 上下文文件中定义的服务,并且我们使用 EL 注入事务属性:
...
<bean id="basicStarTrans" class="java.lang.String">
<constructor-arg value="PROPAGATION_SUPPORTS,readOnly" />
</bean>
...
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*"><b>#{basicStarTrans}</b></prop>
</props>
</property>
我有一些使用 @Service
注释定义的服务。是否可以像我们在 xml 文件中那样注入一个属性,语法是什么? IE:
@Transactional("#{transactionalSettings}")
I have services that are defined in a Spring context file and we are injecting the transactional properties using EL:
...
<bean id="basicStarTrans" class="java.lang.String">
<constructor-arg value="PROPAGATION_SUPPORTS,readOnly" />
</bean>
...
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*"><b>#{basicStarTrans}</b></prop>
</props>
</property>
I have a few services that are defined using the @Service
annotation. Is it possible to inject a property similar to the way we do it in the xml file and what would the syntax be? i.e:
@Transactional("#{transactionalSettings}")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更深入地了解
命名空间。我认为它会满足您的需求:http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html
Have a deeper look at the
<tx:>
namespace. I think it'll have what you need:http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html