我在apache-deltaspike.properties中定义TransactionStrategy,使用 Global Alternatives 配置:
globalAlternatives.org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy=org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy
我的beans.xml只有deltaspike-data模块拦截器:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
<interceptors>
<class>org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor</class>
</interceptors>
</beans>
但是我被下面的异常击中了,这对我来说没有任何意义:
WELD-001409: Ambiguous dependencies for type TransactionStrategy with qualifiers @Default
at injection point [UnbackedAnnotatedField] @Inject private org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor.transactionStrategy
at org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor.transactionStrategy(TransactionalInterceptor.java:0)
Possible dependencies:
- Managed Bean [class org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy] with qualifiers [@Any @Default],
- Managed Bean [class org.apache.deltaspike.jpa.impl.transaction.ResourceLocalTransactionStrategy] with qualifiers [@Any @Default]
显然,默认情况下会激活BeanManagedUserTransactionStrategy替代方案。因为当我删除全局替代定义时,我可以看到deltaspike-data模块使用BeanManagedUserTransactionStrategy。
依赖版本:
- 焊接阴影:3.0.6.Final
- 增量峰值:1.9.3
关于如何绕过它的任何想法?我需要使用ResourceLocalTransactionStrategy。