Integrate Guice component into Spring application

前端 未结 3 616
鱼传尺愫
鱼传尺愫 2021-01-11 21:20

We have a Spring framework based application and need to integrate a component that is built using Google Guice.

Can anybody give us some advice on how this can be

3条回答
  •  余生分开走
    2021-01-11 22:10

    Have a look at the spring-guice project. In particular see the information on accessing modules. I haven't tried it since its not released but I have contemplated copying some of the code.

    The way I have done this in the paste is to just let the Guice components be powered by Guice and retrieve them in either in Spring's Java Config (@Bean) using Guice directly or use a nasty static service locator pattern (ie static method to retrieve component dynamically from Guice).

    The biggest problem I have had regardless of approach is figuring out what boots first since you have competing lifecycles (in theory the spring-guice project would fix this).

提交回复
热议问题