zoukankan      html  css  js  c++  java
  • Spring 3.1.1 + mybatis 3.1.0 + struts2.3.1.2

    Spring 3.1.1 + mybatis 3.1.0  + struts2.3.1.2

    spring config如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
        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-3.1.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context-3.1.xsd
                            http://www.springframework.org/schema/tx
                            http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
                            http://www.springframework.org/schema/aop
                            http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
        <bean id="propertyConfigurer"
                 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
             <property name="location" value="/WEB-INF/jdbc.properties"></property>
        </bean>
        
        <bean id="login" class="test.LoginHandler" scope="prototype">
            <property name="xXinterface" ref="xXinterface"></property>
        </bean>
        
        <bean id="showresult" class="testShowResultHandler" scope="prototype">
            <property name="xXinterface" ref="xXinterface"></property>
        </bean>
        
        <bean id="xXinterface" class="test.XXServiceImpl" scope="prototype">
            <property name="myTestCustomersMapper" ref="myTestCustomersMapper"></property>
            <property name="sqlSession" ref="sqlSession"></property>
        </bean>
        
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="mapperLocations">
                <list>
                    <value>classpath*:test/mapper/**/sqlmaps/**/*.xml</value>
                </list>
            </property>
        </bean>
        
        <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
            <constructor-arg index="0" ref="sqlSessionFactory" />
            <constructor-arg index="1" value="BATCH" />
        </bean>
        
        <bean id="myTestCustomersMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
            <property name="mapperInterface" value="test.mapper.MyTestCustomersMapper" />
            <property name="sqlSessionFactory" ref="sqlSessionFactory" />
        </bean>
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
             <property name="driverClass"><value>${jdbc.driverClassName}</value></property>
             <property name="jdbcUrl"><value>${jdbc.url}</value></property>
             <property name="user"><value>${jdbc.username}</value></property>
             <property name="password"><value>${jdbc.password}</value></property>
             <property name="minPoolSize"><value>1</value></property>
             <property name="maxPoolSize"><value>20</value></property>
             <property name="maxIdleTime"><value>1800</value></property>
             <property name="acquireIncrement"><value>2</value></property>
             <property name="maxStatements"><value>0</value></property>
             <property name="initialPoolSize"><value>2</value></property>
             <property name="idleConnectionTestPeriod"><value>1800</value></property>
             <property name="acquireRetryAttempts"><value>30</value></property>
             <property name="breakAfterAcquireFailure"><value>true</value></property>
             <property name="testConnectionOnCheckout"><value>false</value></property>
        </bean>
        
        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource" />
        </bean>
        
        <tx:advice id="txAdvice" transaction-manager="transactionManager">
            <tx:attributes>
                <tx:method name="get*" read-only="true"/>
                <tx:method name="insert*" propagation="REQUIRED"/>
                <tx:method name="update*" propagation="REQUIRED"/>
                <tx:method name="delete*" propagation="REQUIRED"/>
            </tx:attributes>
        </tx:advice>
        
        <aop:config>
            <aop:pointcut id="defaultServiceTx" expression="execution(* test.service..*.*(..))"/>
            <aop:advisor advice-ref="txAdvice" pointcut-ref="defaultServiceTx"/>
        </aop:config>
    
    </beans>



    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/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        id="webapp1" version="3.0">
        <display-name></display-name>
        
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/springConfig/spring-application.xml</param-value>
        </context-param>
        <context-param>
            <param-name>webAppRootKey</param-name>
            <param-value>pvip.root</param-value>
        </context-param>
        <context-param>
            <param-name>log4jConfigLocation</param-name>
            <param-value>/WEB-INF/log4j.xml</param-value>
        </context-param>
        <listener>
            <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
        </listener>
        
        <filter>
            <filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>
    
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        
        <session-config>
            <session-timeout>1</session-timeout>
          </session-config>
        
        <welcome-file-list>
            <welcome-file>/WEB-INF/login.jsp</welcome-file>
        </welcome-file-list>
        
    </web-app>



    jar包一览

    aopalliance-1.0.jar
    asm-3.3.1.jar
    aspectjweaver-1.6.8.jar
    c3p0-0.9.1.jar
    cglib-2.2.2.jar
    commons-fileupload-1.2.2.jar
    commons-io-2.0.1.jar
    commons-lang-2.5.jar
    commons-logging-1.1.1.jar
    dom4j-1.6.1.jar
    freemarker-2.3.18.jar
    javassist-3.11.0.GA.jar
    jettison-1.1.jar
    jstl-1.1.2.jar
    log4j-1.2.16.jar
    mybatis-3.1.1.jar
    mybatis-spring-1.1.0.jar
    ognl-3.0.4.jar
    ojdbc6.jar
    org.springframework.aop-3.1.1.RELEASE.jar
    org.springframework.asm-3.1.1.RELEASE.jar
    org.springframework.aspects-3.1.1.RELEASE.jar
    org.springframework.beans-3.1.1.RELEASE.jar
    org.springframework.context-3.1.1.RELEASE.jar
    org.springframework.context.support-3.1.1.RELEASE.jar
    org.springframework.core-3.1.1.RELEASE.jar
    org.springframework.expression-3.1.1.RELEASE.jar
    org.springframework.instrument-3.1.1.RELEASE.jar
    org.springframework.instrument.tomcat-3.1.1.RELEASE.jar
    org.springframework.jdbc-3.1.1.RELEASE.jar
    org.springframework.jms-3.1.1.RELEASE.jar
    org.springframework.orm-3.1.1.RELEASE.jar
    org.springframework.oxm-3.1.1.RELEASE.jar
    org.springframework.test-3.1.1.RELEASE.jar
    org.springframework.transaction-3.1.1.RELEASE.jar
    org.springframework.web-3.1.1.RELEASE.jar
    org.springframework.web.portlet-3.1.1.RELEASE.jar
    org.springframework.web.servlet-3.1.1.RELEASE.jar
    org.springframework.web.struts-3.1.1.RELEASE.jar
    slf4j-api-1.6.2.jar
    slf4j-log4j12-1.6.2.jar
    standard-1.1.2.jar
    struts2-core-2.3.1.2.jar
    struts2-spring-plugin-2.3.1.2.jar
    xpp3_min-1.1.4c.jar
    xstream-1.3.jar
    xwork-core-2.3.1.2.jar


  • 相关阅读:
    host 文件位置
    Django 前后端分离开发配置 跨域
    pycharm 关闭单词拼写检查(Typo: In word 'cacheable' )
    Python : argument name should be lowercase 警告处理解决方法
    pycharm 变量名 (Shadows built-in name 'id' )问题
    三体
    12.URL下载网络资源
    11.UDP多线程在线咨询
    10.UDP实现聊天
    9.UDP
  • 原文地址:https://www.cnblogs.com/dqsweet/p/4927753.html
Copyright © 2011-2022 走看看