3

我尝试将 Metro Web 服务与 Spring 集成。但我的错误applicationContext.xml

  <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:ws="http://jax-ws.dev.java.net/spring/core"
        xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://jax-ws.dev.java.net/spring/core 
                            http://jax-ws.dev.java.net/spring/core.xsd
                            http://jax-ws.dev.java.net/spring/servlet 
                            https://jax-ws.dev.java.net/spring/servlet.xsd">
//Some beans

//!!!!!!!!ERROR
    <wss:binding url="/ws">
        <wss:service>
            <ws:service bean="#newsWebService" />
        </wss:service>
    </wss:binding>

    <bean id="newsWebService" class="com.news.webservice.NewsWebService">
        <property name="newsBo" ref="newsBo"/>
    </bean>

</beans>

错误信息:

Multiple annotations found at this line:
    - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wss:binding'.
    - schema_reference.4: Failed to read schema document 'https://jax-ws.dev.java.net/spring/servlet.xsd', because 1) could 
     not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

我添加 lib x-bean-spring-3.7.jar 和 jaxws-spring-1.8.jar

我还检查了 jaxws-spring-1.8.jar 中的 spring.schemas 并得到

# See XBEAN-60. To work around the overwriting issue, this file is maintained manually.
# this file is used by Spring to resolve resources locally.
# the key is the system ID and the value is the actual file location in this jar.
http\://jax-ws.dev.java.net/spring/core.xsd=spring-jax-ws-core.xsd
http\://jax-ws.dev.java.net/spring/servlet.xsd=spring-jax-ws-servlet.xsd
http\://jax-ws.dev.java.net/spring/local-transport.xsd=spring-jax-ws-local-transport.xsd

我根据这个包括了shemas。

#UPDATED 我发现了一些奇怪的东西。我在spring-beans-3.2.0.M1.jarspring.shemas打开

http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.2.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd
http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd

我得到 applicationContext.xml 没有错误只是http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd下一对

请帮我找出原因。

4

5 回答 5

3

编辑:先前的答案已被 eclipse 接受,但在运行时触发了异常。这是我的最终工作配置

使用它,xsd 模式已被移动:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:ws="http://jax-ws.dev.java.net/spring/core"
       xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
            http://jax-ws.dev.java.net/spring/core http://jax-ws.java.net/spring/core.xsd
            http://jax-ws.dev.java.net/spring/servlet http://jax-ws.java.net/spring/servlet.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"
       default-lazy-init="true">

于 2014-03-19T10:35:56.423 回答
2

java.net 托管网站管理员管理员通过更改托管路径引起了问题。

将所有 jax-ws.dev.java.net 更改为 jax-ws.java.net,错误在 2014 年 8 月 28 日消失。

看来,成千上万的开发人员的时间因此而被浪费了。

于 2014-08-28T04:50:15.107 回答
0

尝试更换线路: http://www.springframework.org/schema/beans/spring-beans.xsd因为它冲突。有类似配置的相同问题借用互联网上的一个示例,这解决了它。

于 2014-01-06T04:09:38.187 回答
0

applicationContext.xml 的内容的头部应该是:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ws="http://jax-ws.dev.java.net/spring/core" xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation=
    "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://jax-ws.dev.java.net/spring/core
    http://jax-ws.java.net/spring/core.xsd
    http://jax-ws.dev.java.net/spring/servlet
    http://jax-ws.java.net/spring/servlet.xsd">
于 2015-03-05T08:45:29.200 回答
0

问题是因为不存在 URL http://jax-ws.dev.java.net/

该项目已搬迁并可能停止。然后,我建议另一种解决方案。

  1. 从这个 URL https://repo1.maven.org/maven2/org/jvnet/jax中的源 jar 下载到本地文件(spring-jax-ws-core.xsd,spring-jax-ws-servlet.xsd) -ws-commons/spring/jaxws-spring/1.9/jaxws-spring-1.9-sources.jar
  2. 我已经放置在路径“W:/dev/Spring4WebApp/”中,你可以选择另一个。我建议您将它们上传并发布到您公司的任何自己的服务器上。
  3. 使用以下行修改 appContext:
 <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.springframework.org/schema/c" 
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://jax-ws.dev.java.net/spring/core
file:///W:/dev/Spring4WebApp/spring-jax-ws-core.xsd
http://jax-ws.dev.java.net/spring/servlet
file:///W:/dev/Spring4WebApp/spring-jax-ws-servlet.xsd">

注意以“file:///”开头的行。这些行引用您的本地文件。瞧!它运行!

于 2018-10-05T07:20:06.167 回答