我注意到Spring Integration使用了一个属性" path"在元素" inbound-gateway"中,如文档中所述:
http://docs.spring.io/spring-integration/reference/html/http.html#_request_mapping_support
但是在HTTP集成的XSD中,"路径"属性不存在:
http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
<xsd:element name="inbound-gateway">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation>Defines an inbound HTTP-based Messaging Gateway.</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="gatewayType">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="extract-reply-payload" type="xsd:string" default="true"/>
<xsd:attribute name="supported-methods" type="xsd:string"/>
<xsd:attribute name="view" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.web.servlet.View"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="request-mapper" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.http.InboundRequestMapper"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="request-key" type="xsd:string"/>
<xsd:attribute name="reply-key" type="xsd:string"/>
<xsd:attribute name="reply-timeout" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
这似乎是&#34;接受&#34;的列表属性:
name
extract-reply-payload
supported-methods
view
request-mapper
request-key
reply-key
reply-timeout
&#34;路径&#34;属性不存在于定义中。
效果是我在应用程序开始时出错:
org.xml.sax.SAXParseException; lineNumber: 71; columnNumber: 53; cvc-complex-type.3.2.2: Attribute "path" is not allowed to appear in element "int-http:inbound-gateway".
这是&#34;有罪的&#34;部分配置:
<int-http:inbound-gateway request-channel="receiveChannel"
path="/receiveGateway"
supported-methods="POST"/>
这是不一致的! 也许缺少某些东西?
答案 0 :(得分:1)
当您没有在 pom.xml 中放置足够的依赖项时,通常会发生这种情况。 所以这个具体问题的答案是添加以下代码
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-http</artifactId>
</dependency>
那么您的编译器将不会使用在线 xsd 验证您的 xml,而是使用隐藏在您刚刚添加的依赖项 jar 中的本地 xsd 进行验证。
答案 1 :(得分:0)
我不想在互联网上搜索您正在展示XSD的Spring Integration版本,但这确实已经足够老了,当前和以前的许多版本中肯定存在path
属性:
<xsd:attributeGroup name="inboundCommonAttributes">
<xsd:attribute name="path" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Comma-separated URI paths (e.g., /orderId/{order}).
Ant-style path patterns are also supported (e.g. /myPath/*.do).
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
请考虑一下,在Eclipse中打开Spring Nature,让它从项目中的jar而不是从Internet读取XSD。