英文:
Problem with Quarkus Dependency Injection to JPA Entity Manager
问题
问题与构建相关
由于: io.quarkus.builder.BuildException:
构建失败: 由于错误而构建失败
[error]: 生成步骤 io.quarkus.arc.deployment.ArcProcessor#validate 引发异常: javax.enterprise.inject.spi.DeploymentException: 发现了 2 个部署问题:
[1] 对于类型 javax.persistence.EntityManager 和限定符 [@DataSource(value = "ergoint")]
- java 成员: com.int.dao.EPersistence#entityManagerE
- 在 CLASS bean 上声明 [types=[java.lang.Object, com.int.dao.EPersistence], qualifiers=[@Default, @Any], target=com.int.dao.EPersistence]
[2] 对于类型 javax.persistence.EntityManager 和限定符 [@DataSource(value = "madata")]
- java 成员: com.int.dao.MPersistence#entityManagerM
- 在 CLASS bean 上声明 [types=[com.int.dao.MasterDataPersistence, java.lang.Object], qualifiers=[@Default, @Any], target=com.int.dao.MPersistence]
在 io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:873) 处引发
代码:
@ApplicationScoped
public class MPersistence {
@Inject
@DataSource("madata")
private EntityManager entityManagerMaster;
属性文件:
quarkus.datasource.driver=oracle.jdbc.driver.OracleDriver
quarkus.hibernate-orm.dialect=oracle.jdbc.driver.OracleDriver
quarkus.datasource.madata.url=jdbc:oracle:thin:@myhost:1521:orcl
quarkus.datasource.madata.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.madata.username=quarkus_test
quarkus.datasource.madata.password=quarkus_test
只需从 Eclipse IDE 运行 "maven clean install" 命令,然后在运行测试用例时出现此问题。
(我之前认为这两个类可以使用 @Stateless 从 EJB 中读取,但当我将 quarkus 更新到 1.1.0 final 时,它删除了所有 EJB 依赖项。所以我将应用程序范围设置为 @ApplicationScoped)
英文:
Problem with the build
Caused by: io.quarkus.builder.BuildException:
Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: Found 2 deployment problems:
[1] Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@DataSource(value = "ergoint")]
- java member: com.int.dao.EPersistence#entityManagerE
- declared on CLASS bean [types=[java.lang.Object, com.int.dao.EPersistence], qualifiers=[@Default, @Any], target=com.int.dao.EPersistence]
[2] Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@DataSource(value = "madata")]
- java member: com.int.dao.MPersistence#entityManagerM
- declared on CLASS bean [types=[com.int.dao.MasterDataPersistence, java.lang.Object], qualifiers=[@Default, @Any], target=com.int.dao.MPersistence]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:873)
Code:
@ApplicationScoped
public class MPersistence {
@Inject
@DataSource("madata")
private EntityManager entityManagerMaster;
Properties file:
quarkus.datasource.driver=oracle.jdbc.driver.OracleDriver
quarkus.hibernate-orm.dialect=oracle.jdbc.driver.OracleDriver
quarkus.datasource.madata.url=jdbc:oracle:thin:@myhost:1521:orcl
quarkus.datasource.madata.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.madata.username=quarkus_test
quarkus.datasource.madata.password=quarkus_test
Simply run "maven clean install" from eclipse ide and get this issue while running test case.
(Earlier i think these two classes were readable with @Stateless from EJB but when i update quarkus to 1.1.0 final it removed all EJB dependencies. So i put application scoped)
答案1
得分: 3
自Quarkus 1.8版本以来,我们支持在application.properties中直接设置多个持久化单元。有关更多信息,请参阅https://quarkus.io/guides/hibernate-orm#multiple-persistence-units。
我们目前尚不支持在application.properties中配置多个持久化单元。
因此,您尝试注入的EntityManager不是由Quarkus创建的。
您可以跟踪此问题https://github.com/quarkusio/quarkus/issues/2835,以了解我们在此问题上的进展情况。
英文:
Update: since Quarkus 1.8, we support setting up several persistence units directly in the application.properties. See https://quarkus.io/guides/hibernate-orm#multiple-persistence-units for more information.
We do not support multiple persistence units configured in the application.properties
yet.
Thus the EntityManager
s you try to inject are not created by Quarkus.
You can track this issue https://github.com/quarkusio/quarkus/issues/2835 to be notified of our progress on the subject .
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论