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&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true
jdbc.username=ggs
jdbc.password=ZPIOSVYLXMNI
jdbc.database_name=smart_wms
#url=jdbc:mysql://localhost:3306/cg_tuji?characterEncoding=utf8&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>
applicationContext中普通数据源不用jndi数据源的更多相关文章
- Spring JDBCTemplate使用JNDI数据源
xml配置: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverMana ...
- Spring jndi数据源配置方法
xml配置: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverMana ...
- WebLogic使用总结(三)——WebLogic配置JNDI数据源
一.在WebLogic新建针对Oracle数据库的JNDI数据源 进入weblogic管理控制台,此处是远程访问:http://192.168.1.144:7001/console 点击左侧[ 域结构 ...
- Tomcat中配置JNDI数据源
准备工作: Tomcat版本:tomcat6.0以上 下例中均使用MySQL数据库 将对应数据源的jar包和MySQL的驱动包拷贝至tomcat的lib文件夹下 一.全局数据源 1步骤一:配置 在to ...
- 在平台中使用JNDI 数据源
有些情况下为了系统的安全性考虑,可以将数据源配置成JNDI,在程序中只需要使用 容器的JNDI路径就可以了. 配置方法 1.在容器中配置数据源 <Context path="/&quo ...
- 创建在类路径资源[applicationcontext]中定义名为“工厂”的bean时出错。:在设置bean属性“dataSource”时,无法解析对bean“dataSource”的引用;嵌套异常是org.springframe .beans.factory。BeanCreationException:创建名为“数据源”的bean时出错,该名称是在类路径资源[applicationcontext
控制台报错: 创建在类路径资源[applicationcontext]中定义名为“工厂”的bean时出错.:在设置bean属性“dataSource”时,无法解析对bean“dataSource”的引 ...
- 代码中jndi数据源的支持
项目中基本都使用Spring框架,支持jndi还是很简单的,只需在spring配置文件中加入 <!-- 使用jndi配置数据源 --> <bean id="dataSour ...
- 史上最全最详细JNDI数据源配置说明
转: 史上最全最详细JNDI数据源配置说明 2017年08月05日 17:12:08 万米高空 阅读数 23983 版权声明:本文为博主原创文章,转载请注明出处,尊重劳动成果,谢谢~ https: ...
- 为tomcat动态添加jndi数据源信息
我们在开发项目的时候,总要和数据库打交道,如何获取数据源,以什么样的方式来获取,成为了我们即简单又熟悉而且不得不注意的一个问题. 那么在这里我说三种获取数据源的常用方式: 一.通过配置文件来获取 首先 ...
随机推荐
- String类中的equals是如何重写的
我们知道String中的equals方法是被重写过的,因为object的equals方法是比较的对象的内存地址,而String的equals方法比较的是对象的值. 首先几个知识点: 基本数据类型==比 ...
- elasticsearch-installation
1. 安装Java JDK 移步 :sdfa 2. 下载elasticsearch url : https://artifacts.elastic.co/downloads/elasticsearch ...
- TCP协议与流通信
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! TCP(Transportation Control Protocol)协议与IP ...
- [转]Javascript高性能动画与页面渲染
No setTimeout, No setInterval 作者 李光毅 发布于 2014年4月30日 如果你不得不使用setTimeout或者setInterval来实现动画,那么原因只能是你需要精 ...
- 【转】Pro Android学习笔记(六):了解Content Provider(中)
Content Provider的架构 Authority类似web中的域名,每个content provider会通过AndroidManifest.xml向系统注册authority,如下.其中n ...
- 构造函数参数new class[0]的作用
new Class[0];就是传一个长度为1的Class数组过去.内容为null. new Class[0]表示有零个元素的Class数组,即空数组,与传入null结果是一样的,都表示取得无参构造方法 ...
- 开源.Net项目合集
http://www.cnblogs.com/StrangeCity/p/OpenSourceProject.html
- c# list排序的实现方式
实体类实现IComparable接口,而且必须实现CompareTo方法 实体类定义如下: class Info:IComparable { public int Id { get; set; } p ...
- CF-845B
B. Luba And The Ticket time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- java 原始类与封装类 的区别
int是java提供的8种原始数据类型之一.Java为每个原始类型提供了封装类,Integer是java为int提供的封装类.int的默认值为0,而Integer的默认值为null,即Integer可 ...