Post creation initialization of guice singleton [duplicate]
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Guice call init method after instantinating an object 5 answers Configure an object provided by a Guice Module 2 answers Is there a way to have guice call a init() method after it has instantiated a singleton? Calling init() inside the constructor is not an option since init() could be overriden by a subclass. 回答1: You can use `@PostConstruct' in guice when you use the mycila/jsr250 extension . This will cause your init() method to be called right after instantiation. @PostConstruct void init() { //