为什么 jax-ws spring 服务引用以 # 为前缀,如 ws:service bean=“#myService”
我使用 jax-ws commons 网站上的教程使用 jax-ws 和 Spring 开发了一个 Web 服务。它向您展示了如何从 spring applicationContext 文件定义和引用您的服务 (https:// /jax-ws-commons.dev.java.net/spring/)。
引用 Web 服务时出现“#”的原因是什么?我希望看到更多类似的内容
<ws:service name="myEventWS" ref="eventWebService"/>
,但按照上面链接中的示例,我创建了以下有效的内容。
<bean id="eventWebService" class="com.myws.EventWS">
<property name="model" ref="EventModel"/>
</bean>
<wss:binding url="/EventWS">
<wss:service>
<ws:service bean="#eventWebService"/>
</wss:service>
</wss:binding>
I've developed a web service with jax-ws and Spring using the tutorials at the jax-ws commons website. It shows you how to define and reference your service from your spring applicationContext file (https://jax-ws-commons.dev.java.net/spring/).
What is the reason for the "#" when referencing the web service? I would expect to see something more like
<ws:service name="myEventWS" ref="eventWebService"/>
but following example at the above link I created the following which works.
<bean id="eventWebService" class="com.myws.EventWS">
<property name="model" ref="EventModel"/>
</bean>
<wss:binding url="/EventWS">
<wss:service>
<ws:service bean="#eventWebService"/>
</wss:service>
</wss:binding>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 自定义配置命名空间,这是Spring的一个功能,允许您使用更简单的命名空间来表达复杂的bean图。这些自定义命名空间的含义和解释取决于所讨论的实现,在本例中为 JAX-WS-Commons 项目。看来作者认为bean=#eventWebService
意味着您所说的ref="eventWebService"
。我不知道他们为什么这样做,也许他们认为这样更具可读性......也许他们认为
bean=eventWebService
(没有哈希)意味着一个名称,而不是一个引用。 .. 我不知道。文档也不是很清楚。不管怎样,我很确定它不是 Spring 的核心语法,也不是我以前见过的约定。
<ws:service>
is using a custom configuration namespace, which is a feature of Spring which allow you to express complex bean graphs using simpler namespace. The meaning and interpretation of these custom namespaces is down to the implementation in question, in this case the JAX-WS-Commons project. It seems the authors of that decided thatbean=#eventWebService
means what you refer to asref="eventWebService"
.I don't know whay they did it that way, maybe they thought it was more readable... maybe they thought that
bean=eventWebService
(without the hash) means a name, rather than a reference... I don't know. The documentation isn't very clear either.Either way, I'm pretty sure sure it's not a core Spring syntax, nor a convention that I've seen before.
“#”告诉 bean 它不是一个类,而是一个引用。
华泰
the "#" tells the bean that it's not a class, but rather a ref.
HTH
#eventWebService
指的是EventWebService
类型的 bean(未指定 bean 时根据默认的 Spring 命名约定)。#eventWebService
refers to the bean of typeEventWebService
(according to the default Spring naming convention when bean is is not specified).