spring2.x升级为spring4.x记录-创新互联

一,web.xml修改

修改前

创新互联自2013年起,是专业互联网技术服务公司,拥有项目成都网站设计、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元靖州做网站,已为上家服务,为靖州各地企业和个人服务,联系电话:028-86922220
<servlet>
                <servlet-name>context</servlet-name>
                <servlet-class>
                        org.springframework.web.context.ContextLoaderServlet
                </servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>

修改后

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

二,applicationContext.xml修改

命名空间修改前

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

命名空间修改后

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" 
        xmlns:task="http://www.springframework.org/schema/task" 
    xmlns:tx="http://www.springframework.org/schema/tx"
    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-4.2.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
        http://www.springframework.org/schema/task 
    http://www.springframework.org/schema/task/spring-task-4.2.xsd 
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-4.2.xsd">

二,applicationContext.xml语法差异

spring 4.x 去掉了 dependency-check
引用bean bean=代替了local=

三,xfire-all-1.2.6.jar修改

1.spring 4.x不支持singleton=false

修改文件:org/codehaus/xfire/spring/xfire.xml
org/codehaus/xfire/spring/xfireXmlBeans.xml
singleton="false" 修改为 scope="prototype"
singleton="true" 修改为 scope="singleton"

2.spring-4.*的customEditors获取类型直接指定为Class,而配置默认还是缺省的

修改文件:org/codehaus/xfire/spring/customEditors.xml

<bean id="xfire.customEditorConfigurer"
    class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
      <map>
        <entry key="org.codehaus.xfire.service.ServiceFactory" value="org.codehaus.xfire.spring.editors.ServiceFactoryEditor"></entry>
<!--         <entry key="org.codehaus.xfire.service.ServiceFactory"> -->
<!--           <bean class="org.codehaus.xfire.spring.editors.ServiceFactoryEditor"> -->
<!--             <property name="transportManager" ref="xfire.transportManager" /> -->
<!--           </bean> -->
<!--         </entry> -->
      </map>
    </property>
  </bean>

四. jar包替换

去掉spring.jar
去掉xerces-2.6.2.jar(有可能异常)
定时任务去掉quartz-all-1.6.0.jar(有可能异常)改为使用quartz-2.2.1.jar和quartz-jobs-2.2.1.jar
参考:https://blog.51cto.com/jtech/2318217
添加spring 4.x jar包

<!-- spring begin -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- spring end -->

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。

标题名称:spring2.x升级为spring4.x记录-创新互联
分享网址:https://www.cdcxhl.com/article6/hcjog.html

成都网站建设公司_创新互联,为您提供网站建设网站收录网站导航电子商务App开发建站公司

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

手机网站建设