关于电梯喷油器的问题
据我了解 文档 Lift
提供Injector
特征(及其实现)来注入依赖项,如下所示:
object MyInjector extends Injector {...}
val myThing: Box[Thing] = MyInjector.inject
不幸的是,它对我来说看起来太具有侵入性。我不希望我的业务类依赖于 Injector 特征(及其实现)。我想让我的业务类保持干净并且没有任何框架依赖性。
例如,Spring 在这个意义上就不是侵入性的。也就是说,我不必将 Spring
导入添加到我的业务类中来实现依赖注入。
我错过了什么吗?
As I understand from the documentation Lift
provides Injector
trait (and its implementations) to inject dependencies as follows:
object MyInjector extends Injector {...}
val myThing: Box[Thing] = MyInjector.inject
Unfortunately, it looks too intrusive for me. I don't want my business classes to depend on the Injector
trait (and its implementation). I would like to keep my business classes clean and free of any framework dependencies.
Spring
, for example, is not intrusive in this sense. That is, I do not have to add Spring
imports to my business classes in order to implement dependency injection.
Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不喜欢 Injector 特性(我也不喜欢),则不必使用它。 http://scala.sygneca.com/patterns/component-mixins。您可以坚持蛋糕模式。 Spring 是否为您提供了蛋糕模式无法实现的功能?
If you don't like the Injector trait (neither do I), you do not have to use it. http://scala.sygneca.com/patterns/component-mixins. You can just stick to the cake pattern. Does Spring offer you anything that you can't implement with the cake pattern?