如何在引导阶段注入存储库服务
我有一个名为“NodeUtil”的类,该类在引导阶段注入了三个服务,但是一旦我尝试记录 service.toString() ,打印的值是 proxy$.toString() 。
我正在尝试初始化 NodeUtil bean 中的服务,而不是使用
Repository.getServiceRegistry(FacesContext ...).getSearchService()
我在文件 action-services-context.xml 中使用相同的东西来初始化它们。
- 我创建一个类。
- 我设置了setter方法。
- 我为 NodeUtil Bean 编写了 xml 标签的狙击。
谁能告诉我为什么这会引发错误以及正确的方法是什么。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 @Artefacto 所说,这里没有问题。使用 Spring 时,您会获得对 Proxy 类的引用,该类包装了您要求其初始化的内容。这有很多(有益的)效果,但绝对不是一个错误。
您可以看到 proxy$.toString() 证明您确实拥有所需类的初始化实例的句柄。我强烈建议您阅读更多有关如何 Spring IoC 有效。
As @Artefacto said, there's no issue here. When using Spring, you get a reference to a Proxy class that wraps what you asked it to initialize. This has a number of (beneficial) effects, but definitely it's not an error.
You can see that
proxy$.toString()
as a proof that you really have a handle to an initialized instance of the class you need. I strongly suggest you to read more about how Spring IoC works.