英文:
Quarkus service to use another Quarkus project service
问题
I would like to load one Quarkus project in my other main Quarkus project.
我想在我的另一个主要的 Quarkus 项目中加载一个 Quarkus 项目。
I tried @ApplicationScoped
in the subproject and @Inject
in the main project however object is not getting initialized.
我尝试在子项目中使用 @ApplicationScoped
和在主项目中使用 @Inject
,但是对象没有被初始化。
it throws error javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type
它抛出错误 javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type
if Initialize with new it works
如果使用 new
进行初始化,它可以工作
Like
@Inject
Foo foo
throws error however
像
@Inject
Foo foo
抛出错误,然而
Foo foo = new Foo();
will work but it won't initialize the quarks objects like mongoClinet .. etc.
将起作用,但不会初始化 Quarkus 对象,比如 mongoClinet 等。
英文:
I would like to load one Quarkus project in my other main Quarkus project.
I tried @ApplicationScoped
in the subproject and @Inject
in the main project however object is not getting initialized.
it throws error javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type
if Initialize with new it works
Like
@Inject
Foo foo
throws error however
Foo foo = new Foo();
will work but it won't initialize the quarks objects like mongoClinet .. etc.
答案1
得分: 1
Quarkus在依赖库中不会自动发现bean。
我认为在您的其他项目中添加jandex-maven-plugin并重新打包可以帮助解决这个问题。
有关更多信息,请查看maven-tooling。
英文:
Quarkus doesn't discover beans in the dependents libraries.
I think adding of jandex-maven-plugin for your other project and package it again can help to solve th.
There is more info about that - maven-tooling
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论