如何在引导阶段注入存储库服务

发布于 2024-12-04 17:43:49 字数 426 浏览 1 评论 0 原文

我有一个名为“NodeUtil”的类,该类在引导阶段注入了三个服务,但是一旦我尝试记录 service.toString() ,打印的值是 proxy$.toString() 。

我正在尝试初始化 NodeUtil bean 中的服务,而不是使用

Repository.getServiceRegistry(FacesContext ...).getSearchService()

我在文件 action-services-context.xml 中使用相同的东西来初始化它们。

  • 我创建一个类。
  • 我设置了setter方法。
  • 我为 NodeUtil Bean 编写了 xml 标签的狙击。

谁能告诉我为什么这会引发错误以及正确的方法是什么。

谢谢

I have a class named "NodeUtil" and that class have a three services injected in the bootstrap phase but once i trying to Log the service.toString() the value that printed is
proxy$.toString() .

I'm trying to initialize the services in the NodeUtil bean rather than initialize them using

Repository.getServiceRegistry(FacesContext ...).getSearchService()

I use the same thing in the file action-services-context.xml.

  • I create a class.
  • I set setter methods.
  • I write a snipe of xml tag for NodeUtil Bean.

Can anyone tell me why this initiate an error and what the correct way.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

≈。彩虹 2024-12-11 17:43:49

正如 @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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文