当我在spring bean配置文件中添加命名空间时,我能够大大减少xml配置吗?
例如:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd">
<sws:annotation-driven />
</beans>
此片段允许我不明确定义PayloadRootAnnotationMethodEndpointMapping
答案 0 :(得分:3)
您已指定
<sws:annotation-driven/>
来自文档http://static.springsource.org/spring-ws/site/reference/html/tutorial.html-
使用 我们配置中的元素 启用检测 @PayloadRoot注释。它是 有可能(并且很常见) 多个相关的处理方法 一个端点,每个端点都在处理 不同的XML消息。
它基本上意味着您可以在Java文件中指定注释来定义端点 -
@PayloadRoot(namespace = "http://mycompany.com/hr/schemas", localPart = "HolidayRequest")
因此,您不再需要在XML中指定配置。
答案 1 :(得分:2)
这些是Spring 2.5中流行的“配置宏”。他们在宣布豆类的常规安排时减少了所需的驴工作,用宏取代它们。 Spring中的示例包括<context:annotation-driven/>
。
在您的示例中,<sws:annotation-driven/>
替换了一堆Spring WS端点映射和处理程序bean,否则您必须明确声明它们。
请注意,简单地声明XML命名空间本身并不做任何事情,而<sws:annotation-driven/>
是完成工作的。{/ p>
答案 2 :(得分:0)
当
<sws:annotation-driven />在配置中检测到
,框架自动注册一大堆框架bean来检测端点映射,充当消息接收器等。消息工厂,消息接收器等都是自动注册的。对于更直接的情况,这基本上是一个捷径,我们只想要所有这些bean的默认值。