• applicationContext中普通数据源不用jndi数据源


    applicationContext.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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:tx="http://www.springframework.org/schema/tx" 
        xmlns:jee="http://www.springframework.org/schema/jee"
        xmlns:aop="http://www.springframework.org/schema/aop" 
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:task="http://www.springframework.org/schema/task"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        http://www.springframework.org/schema/aop  http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd">
    
    <!-- <import resource="spring-quartz.xml"/>
    
        <mvc:annotation-driven />     
        <tx:annotation-driven transaction-manager="transactionManager" /> 
        <task:annotation-driven/>  
        <aop:aspectj-autoproxy proxy-target-class="true"/> -->
        
        <!--  加载配置文件-->
        <context:property-placeholder location="classpath:database.properties"/>
            
        <!--  JNDI数据源-->    
         <!-- <jee:jndi-lookup id="dataSource" jndi-name="jndi_wmsc" resource-ref="true"/> -->
    
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">  
            <property name="driverClassName"><value>${jdbc.driverClassName}</value></property>  
            <property name="url"><value>${jdbc.url}</value></property>  
            <property name="username"><value>${jdbc.username}</value></property>  
            <property name="password"><value>${jdbc.password}</value></property>  
            <property name="maxActive"><value>${jdbc.maxActive}</value></property>  
            <property name="maxIdle"><value>${jdbc.maxIdle}</value></property>  
            <property name="maxWait"><value>${jdbc.maxWait}</value></property> 
        </bean>  
        
        <!-- SPRING JDBC -->
        <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
            <property name="dataSource" ref="dataSource" />
        </bean>
        <bean id="namedParameterJdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
            <constructor-arg ref="dataSource"/> 
        </bean>
        
        <!-- SPRING 事务管理-->
        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource" />
        </bean>     
        
      
    </beans>

    database.properties

    #mysql
    jdbc.driverClassName=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql://10.19.105.184:3306/smart_wms?useUnicode=true&amp;characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull&amp;rewriteBatchedStatements=true
    jdbc.username=ggs
    jdbc.password=ZPIOSVYLXMNI
    jdbc.database_name=smart_wms
    #url=jdbc:mysql://localhost:3306/cg_tuji?characterEncoding=utf8&amp;zeroDateTimeBehavior=convertToNull
    #username=root
    #password=123
    #database_name=cg_tuji
    jdbc.initialSize=1
    jdbc.maxActive=100
    jdbc.maxIdle=30
    jdbc.minIdle=1
    jdbc.maxWait=10000

    #oracle
    #diver_name=oracle.jdbc.driver.OracleDriver
    #url=jdbc:oracle:thin:@10.68.111.40:1521:cengle
    #username=test
    #password=test
    #database_name=cengle

     pom.xml

    <dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>1.2.2</version>
    </dependency>

  • 相关阅读:
    转自MicrosoftDDOS处理参考如何:强化 TCP/IP 堆栈安全
    [原创]x.509证书在WCF中的应用(CS篇)
    ExtJs学习笔记(17)_table布局
    Javascript生成GUID
    ExtJs学习笔记(18)_ExtJs嵌入FCK示例
    ExtJs学习笔记(12)_Anchor布局
    再谈web.config/app.config敏感数据加/解密的二种方法
    [转自雨痕]LINQ to SQL Delay Loaded
    ExtJs学习笔记(1)_Hello World!
    aspx超时问题容易忽略的细节
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/7866040.html
Copyright © 2020-2023  润新知