Quarkus服务使用另一个Quarkus项目的服务。

huangapple go评论47阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年2月6日 16:33:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75358969.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定