iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >Spring3整合Ibatis3配置
  • 101
分享到

Spring3整合Ibatis3配置

2023-01-31 07:01:26 101人浏览 泡泡鱼

Python 官方文档:入门教程 => 点击学习

摘要

步骤一:在WEB.xml中配置spring     <context-param>            <param-name>contextConfigLocation</param-name> 

步骤一:在WEB.xml中配置spring
    <context-param>    
        <param-name>contextConfigLocation</param-name>    
        <param-value>classpath*:spring/applicationContext*.xml</param-value>    
    </context-param>

    <!--Spring的ApplicationContext 载入 -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
 
步骤二:配置applicationContext.xml
 
<!--设置配置文件-->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">            
       <property name="locations">            
            <list>            
                 <value>classpath*:/application.properties</value>
                 <value>classpath*:/db.properties</value>  
            </list>            
       </property>            
</bean>        
 
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">    
        <property name="maxActive" value="20" />    
        <property name="maxIdle" value="20" />    
        <property name="maxWait" value="3000" />    
        <property name="testWhileIdle" value="true" />    
        <property name="timeBetweenEvictionRunsMillis" value="3600000" />    
        <property name="validationQuery" value="select 1" />    
        <property name="removeAbandoned" value="true" />    
        <property name="removeAbandonedTimeout" value="1" />    
  <property name="driverClassName" value="${jdbc.driverClassName}" />    
  <property name="url" value="${jdbc.url}" />    
  <property name="username" value="${jdbc.username}" />    
  <property name="passWord" value="${jdbc.password}" />    
    </bean>    
 
  <bean id="sqlSessionFactory" class="org.springframework.ORM.ibatis3.SqlSessionFactoryBean">
    <property name="configLocation" value="classpath:ibatis-config.xml" />
    <property name="dataSource" ref="dataSource" />
  </bean>
  <bean id="sqlSessionTemplate" class="org.springframework.orm.ibatis3.SqlSessionTemplate">
    <property name="sqlSessionFactory" ref="sqlSessionFactory" />
  </bean>
  <!--事务配置-->
  <tx:annotation-driven transaction-manager="transactionManager" />
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" autowire="byName" />
注:db.properties内容如下
jdbcNum=2
jdbc.driverClass=com.Mysql.jdbc.Driver

jdbc.url=jdbc:mysql://192.168.1.1:3306/bookdb?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false
jdbc.username=sophie
jdbc.passworld=123456

--结束END--

本文标题: Spring3整合Ibatis3配置

本文链接: https://www.lsjlt.com/news/191458.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作