简体   繁体   中英

Dependency Injection in play/scala without using constructor injection

After migrating from PlayFramework version 2.4 to version 2.5, I need to inject dependencies.

I'm avoiding to use @Inject for constructor DI as in this the caller class of the class that has @Inject also needs to get the same dependencies injected to call the callee's constructor. This increases code complexity. Please suggest any other way of DI which does not involve injecting to constructor.

MacWire looks like a great tool for constructor injection. It is macro-based and thus typesafe and non invasive. The README page has a very good documentation, definitely worth a look IMHO.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM