zoukankan      html  css  js  c++  java
  • cxf之Caused by: java.lang.RuntimeException: Soap 1.1 endpoint already registered on address /rest

    发布rest服务

    但是spring-cxf-rest.xml中配置的却是

    <jaxws:server address="/weather"....................................

    应当是

    <jaxrs:server address="/weather".....................................

    ===========================羞耻的分割线(真正元凶)=============================

    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
             version="3.1">
      <display-name>Archetype Created Web Application</display-name>
      <!--Spring配置-->
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:spring.xml</param-value>
      </context-param>
      <listener>
        <listener-class>
          org.springframework.web.context.ContextLoaderListener
        </listener-class>
      </listener>
      <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
          <param-name>encoding</param-name>
          <param-value>UTF-8</param-value>
        </init-param>
      </filter>
      <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
      <servlet>
        <servlet-name>SpringMVC</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>classpath:spring-mvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
      </servlet>
      <servlet-mapping>
        <servlet-name>SpringMVC</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
    
      <!-- CXF框架的配置 -->
      <servlet>
        <servlet-name>cxf</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>cxf</servlet-name>
        <url-pattern>/ws/*</url-pattern>
      </servlet-mapping>
    
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
    

      spring.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"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:jdbc.properties</value>
                </list>
            </property>
        </bean>
        <!--<import resource="classpath*:spring-mvc.xml" />-->
        <import resource="classpath*:spring-mybatis.xml" />
        <import resource="classpath*:spring-cxf-rest.xml" />
    
    </beans>
    

      以上字体红色加粗加大部分是更正后的配置~(编辑器原因显示不出来,不过,上面的web.xml和spring.xml是正确的配置).

    更正前:

    web.xml中SpringMVC的配置:<param-value>classpath:spring.xml</param-value>

    Spring.xml中引入spring-mvc.xml的配置:<import resource="classpath*:spring-mvc.xml" />

    也并未注释, 这是配置springmvc时相当于加载了spring的配置文件一次(拆分Spring配置文件时不明确web.xml配置导致)

    而web.xml上部引入spring.xml及配置监听器也已经引入了一次,相当于二次加载spring.xml, 这样一来必然会报如题错误.

    总结:

      磨刀不误砍柴工, 基础性的东西不吃透必然多走弯路, 而且是重复性的弯路.

  • 相关阅读:
    毕业四年,你赚回四年的花费了吗?
    【转】解决VS2008 开发Windows Mobile 项目生成速度慢的问题
    WinCE/Mobile上下滑动浏览DataGrid数据 【转】
    【转】取得汉字拼音的首字母
    漂亮的 Windows Mobile 按钮
    SQLite中的常用操作(总结)
    浅谈HTTP中Get与Post的区别
    Oracle学习之数组
    firefox与ie 的javascript区别
    常用bash shell 脚本
  • 原文地址:https://www.cnblogs.com/yadongliang/p/8179535.html
Copyright © 2011-2022 走看看