购物商城---配置文件介绍

来源:互联网 发布:印刷设计排版软件 编辑:程序博客网 时间:2024/04/29 08:28

这里写图片描述

web.xml

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee"    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"    id="WebApp_ID" version="2.4">    <context-param>        <param-name>contextConfigLocation</param-name>        <param-value>classpath:application-context.xml</param-value>    </context-param>    <!-- spring的监听器 读取spring上下文contextConfigLocation的配置文件,也就是上面的classpath:application-context.xml -->    <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    </listener>    <!-- Oscached Fitter配置 放在中文过滤器之前是因为,如果有缓存数据,就不去controller,所以也就不用中文过滤器 -->    <filter>        <filter-name>CacheFilter</filter-name>        <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class>        <init-param>        <!--缓存时间配置  -->            <param-name>time</param-name>            <param-value>7200</param-value>        </init-param>        <init-param>        <!--缓存域配置  -->            <param-name>scope</param-name>            <param-value>application</param-value>        </init-param>    </filter>    <filter-mapping>    <!--缓存拦截配置  -->        <filter-name>CacheFilter</filter-name>        <url-pattern>/product/display/*</url-pattern>    </filter-mapping>     <!-- 中文过滤器 ,过滤resquest,response -->    <filter>        <filter-name>encoding</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>encoding</filter-name>        <url-pattern>*.do</url-pattern>    </filter-mapping>    <filter-mapping>        <filter-name>encoding</filter-name>        <url-pattern>*.shtml</url-pattern>    </filter-mapping>    <!-- 前台springMVC搭建 -->    <servlet>        <servlet-name>front</servlet-name>        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>        <init-param>            <param-name>contextConfigLocation</param-name>            <param-value>classpath:springmvc-front.xml</param-value>        </init-param>    </servlet>    <!-- 后台springMVC搭建 -->    <servlet>        <servlet-name>back</servlet-name>        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>        <init-param>            <param-name>contextConfigLocation</param-name>            <param-value>classpath:springmvc-back.xml</param-value>        </init-param>    </servlet>    <servlet-mapping>        <servlet-name>front</servlet-name>        <url-pattern>*.shtml</url-pattern>    </servlet-mapping>    <servlet-mapping>        <servlet-name>back</servlet-name>        <url-pattern>*.do</url-pattern>    </servlet-mapping>    <!--验证码 -->    <servlet>        <servlet-name>captcha</servlet-name>        <servlet-class>cn.zhou.common.captcha.JcaptchaServlet</servlet-class>    </servlet>    <servlet-mapping>        <servlet-name>captcha</servlet-name>        <url-pattern>/captcha.svl</url-pattern>    </servlet-mapping></web-app>

application-context.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"><!--读取配置  -->    <import resource="config/*.xml" /></beans>

springmvc-back.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!-- springMVC 扫包,springmvc与spring是子与父关系,下面扫总包 -->    <context:component-scan base-package="cn.zhou"        use-default-filters="false">        <!-- 指定扫描controller,实际上扫描器还扫描了@service,@comment等等注解-,use-default-filters=false代表只扫描该层 -->        <!-- 因为springMVC每一个注解都有一个默认过滤器来,这里使用用默认过滤器是为了不和Spring设置的过滤器冲突 -->        <!-- 扫描自带自动装配,所以可以不写自动装配 -->        <context:include-filter type="annotation"            expression="org.springframework.stereotype.Controller" />    </context:component-scan>    <!-- 配置jsp视图 -->    <bean id="jspViewResolver"        class="org.springframework.web.servlet.view.InternalResourceViewResolver">        <property name="prefix" value="/WEB-INF/back_page/" />        <property name="suffix" value=".jsp" />    </bean>    <!-- 配置全局日期转换器 ,为所有的*.do跳转的后台类添加转换 -->    <bean        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">        <!-- webBindingInitializer是一个接口,往接口内注入实现类 -->        <property name="webBindingInitializer">            <bean class="cn.zhou.core.web.CustomDateEdtor">            </bean>        </property>    </bean>    <!-- 上传图片 -->    <bean id="multipartResolver"        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">        <!-- 最大上传容量 单位b -->        <property name="maxUploadSize" value="1048576" />    </bean></beans>

springmvc-front.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!-- springMVC 扫包,springmvc与spring是子与父关系,下面扫总包 -->    <context:component-scan base-package="cn.zhou"        use-default-filters="false">        <!-- 指定扫描controller,实际上扫描器还扫描了@service,@comment等等注解-,use-default-filters=false代表只扫描该层 -->        <!-- 因为springMVC每一个注解都有一个默认过滤器来,这里使用用默认过滤器是为了不和Spring设置的过滤器冲突 -->        <!-- 扫描自带自动装配,所以可以不写自动装配 -->        <context:include-filter type="annotation"            expression="org.springframework.stereotype.Controller" />    </context:component-scan>    <!-- 配置jsp视图 -->    <bean id="jspViewResolver"        class="org.springframework.web.servlet.view.InternalResourceViewResolver">        <property name="prefix" value="/WEB-INF/front_page/" />        <property name="suffix" value=".jsp" />    </bean>    <!-- 方法注解 映射器 -->    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">        <property name="interceptors">            <list>                <bean class="cn.zhou.core.web.SpringmvcInterceptor">                <!--adminId 配置是为了开发人员使用的权限  -->                    <property name="adminId" value="1"/>                 </bean>            </list>        </property>    </bean>    <!--方法注解 适配器 -->    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/></beans>

jdbc.properties

driverClass=com.mysql.jdbc.DriverjdbcUrl=jdbc:mysql://localhost:3306/xxx?characterEncoding=UTF-8user=rootpassword=root

annotation.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!-- 只扫描server包 ,使用排除法,先扫总包,排除controller的包就是service包,让service注解的类都实例化 -->    <context:component-scan base-package="cn.zhou">        <context:exclude-filter type="annotation"            expression="org.springframework.stereotype.Controller" />    </context:component-scan>    <!-- 自动装配 -->    <context:annotation-config /></beans>

captcha.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-3.0.xsd"    default-lazy-init="true">    <bean id="captchaService" class="com.octo.captcha.service.multitype.GenericManageableCaptchaService">        <!-- 图片引擎 -->        <constructor-arg index="0" ref="imageEngine"/>        <constructor-arg type="int" index="1" value="180"/>        <constructor-arg type="int" index="2" value="100000"/>        <constructor-arg type="int" index="3" value="75000"/>    </bean>    <!-- 图片引擎 -->    <bean id="imageEngine" class="com.octo.captcha.engine.GenericCaptchaEngine">        <constructor-arg index="0">            <list>                <ref bean="captchaFactory"/>            </list>        </constructor-arg>    </bean><!-- 验证码工厂 -->    <bean id="captchaFactory" class="com.octo.captcha.image.gimpy.GimpyFactory">        <constructor-arg>            <ref bean="wordgen"/>        </constructor-arg>        <constructor-arg>            <ref bean="wordtoimage"/>        </constructor-arg>    </bean>    <bean id="wordgen" class= "com.octo.captcha.component.word.wordgenerator.RandomWordGenerator">              <!--可选字符-->        <constructor-arg>            <value>aabbccddeefgghhkkmnnooppqqsstuuvvwxxyyzz</value>        </constructor-arg>    </bean>    <bean id="wordtoimage" class="com.octo.captcha.component.image.wordtoimage.ComposedWordToImage">        <constructor-arg index="0">            <ref bean="fontGenRandom"/>        </constructor-arg>        <constructor-arg index="1">            <ref bean="backGenUni"/>        </constructor-arg>        <constructor-arg index="2">            <ref bean="decoratedPaster"/>        </constructor-arg>    </bean>    <bean id="fontGenRandom" class="com.octo.captcha.component.image.fontgenerator.RandomFontGenerator">        <!--最小字体-->        <constructor-arg index="0">            <value>26</value>        </constructor-arg>        <!--最大字体-->        <constructor-arg index="1">            <value>34</value>        </constructor-arg>        <constructor-arg index="2">            <list>                <bean class="java.awt.Font">                <!--Arial是一种字体  -->                    <constructor-arg index="0"><value>Arial</value></constructor-arg>                    <constructor-arg index="1"><value>0</value></constructor-arg>                    <constructor-arg index="2"><value>32</value></constructor-arg>                </bean>            </list>        </constructor-arg>    </bean>    <bean id="backGenUni" class="com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator">        <!--背景宽度-->        <constructor-arg index="0">            <value>110</value>        </constructor-arg>        <!--背景高度-->        <constructor-arg index="1">            <value>50</value>        </constructor-arg>    </bean>    <bean id="decoratedPaster" class="com.octo.captcha.component.image.textpaster.DecoratedRandomTextPaster">        <!--最大字符长度-->        <constructor-arg type="java.lang.Integer" index="0">            <value>4</value>        </constructor-arg>        <!--最小字符长度-->        <constructor-arg type="java.lang.Integer" index="1">            <value>4</value>        </constructor-arg>        <!--文本颜色-->        <constructor-arg index="2">            <ref bean="colorGen"/>        </constructor-arg>        <!--文本混淆-->        <constructor-arg index="3">            <list>                <!--<ref bean="baffleDecorator"/>-->            </list>        </constructor-arg>    </bean>     <bean id="baffleDecorator" class="com.octo.captcha.component.image.textpaster.textdecorator.BaffleTextDecorator">        <constructor-arg type="java.lang.Integer" index="0"><value>1</value></constructor-arg>        <constructor-arg type="java.awt.Color" index="1"><ref bean="colorWrite"/></constructor-arg>    </bean>    <bean id="colorGen" class="com.octo.captcha.component.image.color.SingleColorGenerator">        <constructor-arg type="java.awt.Color" index="0">            <ref bean="colorBlack"/>        </constructor-arg>    </bean>    <bean id="colorWrite" class="java.awt.Color">        <constructor-arg type="int" index="0">            <value>255</value>        </constructor-arg>        <constructor-arg type="int" index="1">            <value>255</value>        </constructor-arg>        <constructor-arg type="int" index="2">            <value>255</value>        </constructor-arg>    </bean>    <bean id="colorBlack" class="java.awt.Color">        <constructor-arg type="int" index="0">            <value>50</value>        </constructor-arg>        <constructor-arg type="int" index="1">            <value>50</value>        </constructor-arg>        <constructor-arg type="int" index="2">            <value>50</value>         </constructor-arg>    </bean></beans>

freemarker.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!--配置freemarker的实现类 -->    <bean id="staticPageService" class="cn.zhou.core.service.staticpage.StaticPageServiceImpl">        <!-- set注入 -->        <property name="freeMarkerConfigurer">            <bean                class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">                <!--配置模板加载路径 -->                <property name="templateLoaderPath" value="/WEB-INF/ftl/"></property>                <!--配置读取模板的语言格式 -->                <property name="defaultEncoding" value="UTF-8"></property>            </bean>        </property>    </bean></beans>

jdbc.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!-- c3p0配置,读取数据库配置文件 -->    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">        <property name="driverClass" value="${driverClass}" />        <property name="jdbcUrl" value="${jdbcUrl}"></property>        <property name="user" value="${user}" />        <property name="password" value="${password}" />    </bean></beans>

memcached.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!-- memcached配置 -->    <!-- 配置客户端 -->    <bean id="memCachedClient" class="com.danga.MemCached.MemCachedClient">        <!-- 设置连接池 -->        <constructor-arg>            <value>sockIOPool</value>        </constructor-arg>    </bean>    <!--memcached连接池,帮助其实例化 -->    <!-- factory-method="getInstance" 实例化 -->    <!-- init-method="initialize" 初始化 -->    <!-- destroy-method="shutDown" 销毁 -->    <bean id="sockIOPool" class="com.danga.MemCached.SockIOPool"        factory-method="getInstance" init-method="initialize" destroy-method="shutDown">        <!-- 将自己的引用以构造的形式注入自己类 -->        <constructor-arg>            <value>sockIOPool</value>        </constructor-arg>        <property name="servers">            <list>                <!-- 配置memcached服务器的地址,如果有多个服务器,重复写value -->                <value>192.168.44.128:11211</value>            </list>        </property>        <!-- 设置权重 ,权重与上面memcached服务器地址一一对应 -->        <property name="weights">            <list>                <value>1</value>            </list>        </property>    </bean>    <!-- memcached切面对象 -->    <bean id="cacheInterceptor" class="cn.zhou.common.web.aop.CacheInterceptor">        <property name="expiry" value="1800"></property>    </bean>    <!-- spring aop 配置 get* 环绕 -->    <aop:config>        <!--面 -->        <aop:aspect ref="cacheInterceptor"><!--            切点            切点为service层的get* 方法            *cn.zhou.core.servi 会报错误 Caused by: java.lang.IllegalArgumentException:                 Pointcut is not well-formed,要改为* cn.zhou.c                数据查询的缓存 -->            <aop:around method="doAround" pointcut="execution(* cn.zhou.core.service.*.*.get*(..))" />        <!--        数据更新,更新memcached ,方法是删掉查询的时候保存的key -->            <aop:after method="doAfter" pointcut="execution(* cn.zhou.core.service.*.*.update*(..))" />            <aop:after method="doAfter" pointcut="execution(* cn.zhou.core.service.*.*.add*(..))" />            <aop:after method="doAfter" pointcut="execution(* cn.zhou.core.service.*.*.delete*(..))" />        </aop:aspect>    </aop:config></beans>

mybatis.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!--有接口配置,mybatis sessionFactory配置 -->    <bean id="SqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">        <!-- 数据源 jdbc.xml的数据源配置 -->        <property name="dataSource" ref="dataSource" />        <!-- 模板配置 ,读取的是mybatis接口配置模板,自动扫描mapping.xml文件 -->        <property name="mapperLocations" value="classpath:cn/zhou/core/dao/*.xml" />        <!-- 别名,别名包,包下的就不要起别名了,直接扫描包 ,这样bean下就不要起别名了,可以省了一个配置文件,mybaits的配置文件的类名就不要用全路径了 -->        <property name="typeAliasesPackage" value="cn.zhou.core.bean,cn.zhou.core.query" />    </bean>    <!-- mybaits扫包 -->    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">        <!-- 基本包,指向接口dao,该接口dao,与mybaitis配置dao,发布的时候是放在一起的 -->        <property name="basePackage" value="cn.zhou.core.dao" />    </bean></beans>

property.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!-- 读取jdbc配置 -->    <bean        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">        <!--locations代表一个集合 -->        <property name="locations">            <list>                <!-- 读取jdbc配置 -->                <value>classpath:properties/jdbc.properties</value>            </list>        </property>    </bean></beans>

transation.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!-- spring jdbc事务 -->    <bean id="transactionManager"        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">        <!-- 配置数据源 -->        <property name="dataSource" ref="dataSource" />    </bean>    <!-- 开启事务注解 -->    <tx:annotation-driven transaction-manager="transactionManager" /></beans>

util.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:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"    xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">    <!-- Session实例化 -->    <!-- 本地Session实例化 -->    <bean id="sessionProvider" class="cn.zhou.common.web.session.HttpSessionProvider"/>    <!-- 远程Session实例化 --><!--    <bean id="sessionProvider" class="cn.zhou.common.web.session.CacheSessionProvider"/> -->    <!-- Md5加密 -->    <bean id="md5Pwd" class="cn.zhou.common.encode.Md5PwdImpl"/></beans>
0 0
原创粉丝点击