Emr*_*sik 12 java multi-module quarkus
首先,我有一个像这样的多模块Maven层次结构:
??? project (parent pom.xml)
? ??? service
? ??? api-library
Run Code Online (Sandbox Code Playgroud)
所以现在问题来了:
我在使用api库中的类的服务模块中编写了JAX-RS端点。
当我开始quarkus时,我得到以下警告:
13:01:18,784 WARN [io.qua.dep.ste.ReflectiveHierarchyStep] Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:
- com.example.Fruit
- com.example.Car
Consider adding them to the index either by creating a Jandex index for your dependency or via quarkus.index-dependency properties.
Run Code Online (Sandbox Code Playgroud)
这两个类com.example.Fruit和com.example.Car位于在api-library模块。
所以我想我需要将它们添加到application.properties中的Jandex索引依赖项中。
但是如何将Jandex索引依赖项添加到quarkus中呢?
Gui*_*met 12
Quarkus自动索引主模块,但是,当您有包含CDI bean,实体,序列化为JSON的对象的附加模块时,您需要显式索引它们。
有两种不同的方法(易于实现)。
使用Jandex Maven插件
只需将以下内容添加到您的pom.xml中:
<build>
<plugins>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.7</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
如果您的依赖关系在项目外部,并且您想要一劳永逸地建立索引,那么这是最有益的选择。
添加一个空的META-INF / beans.xml
如果您在中添加了一个空META-INF/beans.xml文件src/main/resources,则这些类也会被索引。
这些类将由Quarkus自己索引。
索引其他依赖项
如果您不能修改依赖关系(例如,考虑第三方依赖关系),则仍可以通过在您的条目中添加一个条目来对其进行索引application.properties:
quarkus.index-dependency.<name>.group-id=
quarkus.index-dependency.<name>.artifact-id=
quarkus.index-dependency.<name>.classifier=(this one is optional)
Run Code Online (Sandbox Code Playgroud)
与<name>作为一个名字你选择,以确定你的依赖。
| 归档时间: |
|
| 查看次数: |
1914 次 |
| 最近记录: |