相当于春季的Google Guice Injector

时间:2016-11-29 18:17:53

标签: spring guice

目前我有一些使用Google Guice启动服务器的代码:

   Injector injector = createInjector(
        new Module(root, domain, realm),
        new TestsArtefactsServiceModule()


   final Server server = injector.getInstance(Server.class);
   server.acquire();
   server.activate();
   getRuntime().addShutdownHook(new Thread(() -> stopServer(server)));

我需要将其更改为使用Spring。

Spring中是否有相当于Guice Injector的类?或者,还有其他方法可以实现这一目标吗?

1 个答案:

答案 0 :(得分:2)

在Spring中,它是您正在寻找的ApplicationContext。

这两个框架有一个比较: http://www.theserverside.com/feature/Comparing-Spring-vs-Google-Guice-By-Example

相关问题