经过最初的努力,使用下面的设置制作了EntityManager
之后,我最终发现了IllegalArgumentException: ResourceLoader must not be null
,我不知道。 spring-data-jpa 2.1.1.RELESE,JBoss EAP 7.1。我想念什么吗?
Caused by: java.lang.IllegalArgumentException: ResourceLoader must not be null
at org.springframework.util.Assert.notNull(Assert.java:115)
at org.springframework.core.io.support.ResourcePatternUtils.getResourcePatternResolver(ResourcePatternUtils.java:62)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.setResourceLoader(ClassPathScanningCandidateComponentProvider.java:265)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.<init>(ClassPathScanningCandidateComponentProvider.java:150)
at org.springframework.data.repository.config.CustomRepositoryImplementationDetector.findCandidateBeanDefinitions(CustomRepositoryImplementationDetector.java:122)
at org.springframework.data.repository.config.CustomRepositoryImplementationDetector.lambda$detectCustomImplementation$1(CustomRepositoryImplementationDetector.java:107)
at java.util.Optional.orElseGet(Optional.java:267)
at org.springframework.data.repository.config.CustomRepositoryImplementationDetector.detectCustomImplementation(CustomRepositoryImplementationDetector.java:107)
at org.springframework.data.repository.cdi.CdiRepositoryContext.getCustomImplementationClass(CdiRepositoryContext.java:143)
at org.springframework.data.repository.cdi.CdiRepositoryBean.getCustomImplementationBean(CdiRepositoryBean.java:457)
at org.springframework.data.repository.cdi.CdiRepositoryBean.getRepositoryFragments(CdiRepositoryBean.java:372)
at org.springframework.data.repository.cdi.CdiRepositoryBean.create(CdiRepositoryBean.java:344)
at org.springframework.data.jpa.repository.cdi.JpaRepositoryBean.create(JpaRepositoryBean.java:72)
at org.springframework.data.repository.cdi.CdiRepositoryBean.create(CdiRepositoryBean.java:216)
at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:99)
at au.com.cba.reporting.db.JpaRepository$ReportingParameterRepository$845402535$Proxy$_$$_WeldClientProxy.findAll(Unknown Source)
at au.com.cba.reporting.ReportingBean.findAll(ReportingBean.java:25)
...
beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all"/>
Cdi Config
@ApplicationScoped
public class CdiConfig {
@Produces
@Dependent
@PersistenceContext(unitName = "jdbc-tx")
private EntityManager entityManager;
}
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="jdbc-tx" transaction-type="JTA">
<jta-data-source>java:/JDBC_TX_DATASOURCE</jta-data-source>
</persistence-unit>
</persistence>
答案 0 :(得分:0)
此问题是由依赖项版本不匹配引起的。出于某种原因,所有以传递方式拉入的Spring库均为5.1.1.RELEASE版本,只有spring-core是4.2.5.RELEASE。
通过为所涉及的库引入依赖关系管理并使它们全部符合5.1.1.RELEASE进行排序。