Using Google Guice to inject java properties

前端 未结 5 1041
灰色年华
灰色年华 2021-02-02 14:24

I want to use google guice to make properties available in all classes of my application. I defined a Module which loads and binds the properties file Test.properties.<

5条回答
  •  醉酒成梦
    2021-02-02 14:47

    "Now my question. If my TestImpl creates other classes where I also need to inject properties, and those classes also need to inject properties what is the correct way to do this?"

    Rule of thumb: avoid the use of "new" Unless it is absolutely necessary, dont let your Impl Class "create other classes". Instead, tell your TestImpl that when created with guice, it should get the required instances injected.

提交回复
热议问题