Why there's no configuration file at all for dependency injection with Google Guice?

后端 未结 6 2286
生来不讨喜
生来不讨喜 2021-02-19 23:51

I am checking out Google Guice as DI framework but I am a bit puzzled: why there\'s no configuration file at all?

I found a partial explanation on this question but it i

6条回答
  •  庸人自扰
    2021-02-20 00:43

    A lot of configuration in Guice is implicit, via the @Inject Annotation. A great deal of complexity in projects comes from a big number of project Artifacts. Java files, Xml files, Properties files, databases, parameters.. Guice tries to remove a part of this complexity by not using config files.

    Re-wiring your application is easy at compile time. Most likely you will only need to edit your module class. For most classes handeled by Guice, you will need no config at all, but only @Inject in the right places - you will only need to configure anything when you have two different Implementations of the same Interface - or when you want to inject classes from external libraries using Provider classes.

提交回复
热议问题