spring+ibatis xml文件配置


applicationContext-jdbc.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
Application context definition for PetClinic on JDBC.
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <context:property-placeholder location="classpath:jdbc.properties"/>
   
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass" value="${jdbc.driverClassName}"/>
        <property name="jdbcUrl" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="minPoolSize" value="5" />  
        <property name="maxPoolSize" value="50" />  
        <property name="maxIdleTime" value="60" />  
        <property name="acquireIncrement" value="3" />  
        <property name="maxStatements" value="0" />  
        <property name="initialPoolSize" value="3" />  
        <property name="idleConnectionTestPeriod" value="60" />  
        <property name="acquireRetryAttempts" value="30" />
        <property name="acquireRetryDelay" value="1000" /> 
        <property name="breakAfterAcquireFailure" value="false" />  
        <property name="testConnectionOnCheckout" value="false" />
   </bean>
  
    <bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>
   
    <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true">
        <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"/>
    </bean>
   
    <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor"
   lazy-init="true"/>
  
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
p:dataSource-ref="dataSource"/>
   
    <bean id="sqlMapClient" name="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:sql-map-config.xml"/>
<property name="dataSource" ref="dataSource"/>
   </bean>
  
<bean id="demoUserDwr" class="com.ys.demo.dwr.DemoUserDwr">
<property name="demoUserService" ref="demoUserService" />
</bean>


<context:annotation-config/>

     <context:component-scan base-package="com.ys.demo.dao">
     </context:component-scan>
     <context:component-scan base-package="com.ys.demo.service">
     </context:component-scan>

  <tx:annotation-driven proxy-target-class="false" transaction-manager="transactionManager" mode="proxy"/>
</beans>


dwr.xml
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr//dwr20.dtd">

<dwr>
  <allow>
    <create creator="spring" javascript="DemoUser">
      <param name="beanName" value="demoUserDwr"/>
     
      <!-- 允许访问的方法 -->
     <include method="addDemoUser"/>
     
      <!-- 拒绝访问的方法 -->
      <!-- <exclude method="addDemoUser"/>-->
    </create>
  </allow>
</dwr>

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
    </context-param>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext-jdbc.xml </param-value>
    </context-param>
   
    <filter>
<filter-name>EncodeFilter</filter-name>
<filter-class>com.ys.demo.common.EncodeFilter</filter-class>
<init-param>
<param-name>encode</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
    <filter-mapping>
<filter-name>EncodeFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
   
    <servlet>
        <servlet-name>dwr-invoker</servlet-name>
        <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>dwr-invoker</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
   
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

你可能感兴趣的:(spring,xml,Web,ibatis,DWR)