第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在夸庫斯中為外部模塊中的類創(chuàng)建 Jandex 索引

如何在夸庫斯中為外部模塊中的類創(chuàng)建 Jandex 索引

瀟湘沐 2022-09-21 16:58:00
首先,我有一個多模塊的 maven 層次結構,如下所示:├── project (parent pom.xml)│   ├── service│   ├── api-library所以現(xiàn)在來看看問題:我正在服務模塊中編寫一個 JAX-RS 端點,該模塊使用 API 庫中的類。當我開始夸庫時,我收到這樣的警告: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.CarConsider adding them to the index either by creating a Jandex index for your dependency or via quarkus.index-dependency properties.這兩個類和位于模塊中。com.example.Fruitcom.example.Carapi-library因此,我認為我需要將它們添加到應用程序?qū)傩灾械?Jandex 索引依賴項中。但是,如何將 Jandex 索引依賴性添加到夸庫斯中呢?
查看完整描述

3 回答

?
哆啦的時光機

TA貢獻1779條經(jīng)驗 獲得超6個贊

Quarkus 會自動為主模塊編制索引,但是,當您有其他模塊包含序列化為 JSON 的 CDI Bean、實體、對象時,您需要顯式索引它們。


有幾個不同(易于實現(xiàn))的選項可以做到這一點。


使用詹德克斯·馬文插件


只需將以下內(nèi)容添加到附加模塊 pom.xml:


<build>

  <plugins>

    <plugin>

      <groupId>org.jboss.jandex</groupId>

      <artifactId>jandex-maven-plugin</artifactId>

      <version>1.2.3</version>

      <executions>

        <execution>

          <id>make-index</id>

          <goals>

            <goal>jandex</goal>

          </goals>

        </execution>

      </executions>

    </plugin>

  </plugins>

</build>

如果你的依賴項位于項目外部,并且你想要一勞永逸地生成索引,則這是最有益的選擇。


使用漸變詹德克斯插件


如果您使用的是 Gradle,則有一個第三方插件允許生成 Jandex 索引:https://github.com/kordamp/jandex-gradle-plugin 。


添加一個空的元 INF/豆.xml


如果在附加模塊中添加一個空文件,則類也將被索引。META-INF/beans.xmlsrc/main/resources


這些類將由夸庫斯本身編制索引。


索引其他依賴項


如果無法修改依賴項(例如,考慮第三方依賴項),仍可以通過向 以下項添加條目來為其編制索引:application.properties


quarkus.index-dependency.<name>.group-id=

quarkus.index-dependency.<name>.artifact-id=

quarkus.index-dependency.<name>.classifier=(this one is optional)

作為您選擇的名稱來標識您的依賴關系。<name>


查看完整回答
反對 回復 2022-09-21
?
波斯汪

TA貢獻1811條經(jīng)驗 獲得超4個贊

現(xiàn)在,在我的微服務中,我廣泛使用注釋中的屬性。這是根據(jù)文檔的屬性說明:targetsRegisterForReflection


/**

 * Alternative classes that should actually be registered for reflection instead of the current class.

 *

 * This allows for classes in 3rd party libraries to be registered without modification or writing an

 * extension. If this is set then the class it is placed on is not registered for reflection, so this should

 * generally just be placed on an empty class that is not otherwise used.

 */

這在基于夸庫的項目上工作得很好,并且當您想要注冊幾個POJO進行反射時,可以處理基本情況。注釋將自行注冊 POJO,但不會從 POJO 的方法注冊返回類型。RegisterForReflection


更高級的方法是使用此處所述的注釋。我正在將其與反射庫和定制的實用程序包裝器一起使用:反射實用程序@AutomaticFeature


現(xiàn)在我可以做更復雜的任務了:


@AutomaticFeature

@RegisterForReflection(targets = {

        com.hotelbeds.hotelapimodel.auto.convert.json.DateSerializer.class,

        TimeDeserializer.class,

        DateSerializer.class,

        TimeSerializer.class,

        RateSerializer.class,

})

public class HotelBedsReflection implements Feature {

    public static Logger log = Utils.findLogger(Reflections.class);


    @Override

    public void beforeAnalysis(BeforeAnalysisAccess access) {

        ReflectUtils.registerPackage(LanguagesRQ.class.getPackage().getName(), Object.class);

        ReflectUtils.registerPackage(AvailabilityRQ.class.getPackage().getName(), Object.class);

        ReflectUtils.registerPackage(Occupancy.class.getPackage().getName(), Object.class);

    }

}

初始答案

我嘗試添加 Jandex 索引,添加 bean.xml以及索引其他依賴項,如 @emre-i??k 答案中所述,但是我的第三方類 (EpAutomationRs) 未注冊為在本機模式下進行反射。因此,我最終獲得了快速而骯臟的解決方案來注冊它(見下文)。我創(chuàng)建了一個未使用的 REST JSON 終結點,該終結點返回該類。


/**

 * the purpose of this method is to register for reflection EpAutomationRs class

 *

 * @return

 */

@GET

@Path(GET_EMPTY_RS)

@Produces(MediaType.APPLICATION_JSON)

public EpAutomationRs entry() {

    return new EpAutomationRs();

}


查看完整回答
反對 回復 2022-09-21
?
牧羊人nacy

TA貢獻1862條經(jīng)驗 獲得超7個贊

對于分級用戶,您可以在所依賴模塊的 build.gradle 中使用此插件。


查看完整回答
反對 回復 2022-09-21
  • 3 回答
  • 0 關注
  • 199 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號