3
我需要將什麼添加到contextInitialized
方法才能正確初始化對象圖?如何用匕首初始化Web應用程序?
鑑於這把匕首模塊:
@Module
public class MapperModule {
@Provides
@Singleton
ObjectMapper provideObjectMapper() {
return new ObjectMapper();
}
}
了ServletContextListener的子類:
public class DaggerDi implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
ObjectGraph objectGraph = ObjectGraph.create(new MapperModule());
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}
而且在web.xml
<web-app>
<display-name>Archetype Created Web Application</display-name>
<listener>
<listener-class>
com.me.config.DaggerDi
</listener-class>
</listener>
</web-app>