spring的数据源基本配置
aplictaionContext-dataSource的配置:
<?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:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/jee http://www.springframework.org/schema/jee/spring-jee-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/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config.properties</value>
</list>
</property>
</bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>${sqlDriver}</value>
</property>
<property name="url">
<value>${sqlUrl}</value>
</property>
<property name="username">
<value>${sqlUserName}</value>
</property>
<property name="password">
<value>${sqlPassword}</value>
</property>
<property name="maxActive">
<value>${sqlMaxActive}</value>
</property>
<property name="maxWait">
<value>${sqlMaxWait}</value>
</property>
<property name="maxIdle">
<value>${sqlMaxIdle}</value>
</property>
</bean> </beans>
propertyConfigurer用来配置用到的config.properties文件的位置,方便在datasource配置中引用。
config配置文件的写法如下:
sqlDriver=com.mysql.jdbc.Driver
sqlUrl=jdbc:mysql://127.0.0.1:3306/mydatabase?useUnicode=true&characterEncoding=utf8
sqlUserName=root
sqlPassword=123
sqlMaxActive=500
sqlMaxWait=1000
sqlMaxIdle=50
记录下来供以后配置时参考。
spring的数据源基本配置的更多相关文章
- Spring多数据源的配置和使用
1. 配置多个数据源 最近开发一个数据同步的小功能,需要从A主机的Oracle数据库中把数据同步到B主机的Oracle库中.当然能够用dmp脚本或者SQL脚本是最好,但是对于两边异构的表结构来说,直接 ...
- spring+hibernate 配置多个数据源过程 以及 spring中数据源的配置方式
spring+hibernate 配置多个数据源过程 以及 spring中数据源的配置方式[部分内容转载] 2018年03月27日 18:58:41 守望dfdfdf 阅读数:62更多 个人分类: 工 ...
- Spring动态数据源的配置
Spring动态数据源 我们很多项目中业务都需要涉及到多个数据源,就是对不同的方法或者不同的包使用不同的数据源.最简单的做法就是直接在Java代码里面lookup需要的数据源,但是这种做法耦合性太高, ...
- Spring boot 数据源未配置异常
问题 在使Springboot自动生成的项目框架时如果选择了数据源,比如选择了mysql,生成项目之后,启动会报一下异常: Description: Cannot determine embedded ...
- 各种数据库(oracle、mysql、sqlserver等)在Spring中数据源的配置和JDBC驱动包----转
在开发基于数据库的应用系统时,需要在项目中进行数据源的配置来为数据 库的操作取得数据库连接.配置不同数据库的数据源的方法大体上都是相同的,不同的只是不同数据库的JDBC驱动类和连接URL以及相应的数据 ...
- spring多数据源的配置
C3P0和DBCP的区别 C3P0是一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规范和JDBC2的标准扩展.目前使用它的开源项目有Hibernate,Spring等. d ...
- spring多数据源的配置(转)
C3P0和DBCP的区别 C3P0是一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规范和JDBC2的标准扩展.目前使用它的开源项目有Hibernate,Spring等. d ...
- spring多数据源事务配置
项目中遇到多数据源问题, 对于每个数据源需要单独完成事务控制, 这里记录下具体实现方法 在spring配置文件中 定义两个数据源 <!-- 数据源定义(spring-jndi) --> ...
- 基于注解的Spring多数据源配置和使用
前一段时间研究了一下spring多数据源的配置和使用,为了后期从多个数据源拉取数据定时进行数据分析和报表统计做准备.由于之前做过的项目都是单数据源的,没有遇到这种场景,所以也一直没有去了解过如何配置多 ...
随机推荐
- VC 隐藏托盘图标
苦苦寻找的隐藏托盘图标的方法,今天终于搞定,献给大家! #include <atlbase.h> #include <atlconv.h> #include <CommC ...
- pywin32 安装错误 ImportError: DLL load failed: 不是有效的 Win32 应用程序
pywin32 安装错误 ImportError: DLL load failed: 不是有效的 Win32 应用程序. 发现是因为没有制定Pywin32的dll所致,我们在用Pywin32开发时, ...
- cp 提示 overwrite 问题
cp 提示 overwrite 问题 copy -f 文件的时候仍然提示覆盖问题,很诧异,咨询SA,果然 cp -i 强制要求覆盖文件的时候确认,-f 也不起作用,大大的不爽[root@erpappd ...
- linux下的shell和脚本
1.各种Unix shell linux下的shell基本是从unix环境中的shell发展而来,贴一下wiki:其中我们常用的,可归类为Bourne Shell(/usr/bin/sh或/bin/s ...
- 批量更新sql |批量update sql
图所示现需要批量更新table2表内字段Pwd更新userName对IP地址username与Ip对应关系table1所示 update table2 set pwd=table1.ip from t ...
- [HEOI 2013 day2] SAO (树形动态规划)
题目大意 给一棵N个节点的有向树(N <= 1000),求其拓扑序列个数. 思路 我们将任意一个点作为根,用dp[i][j]表示以节点i为根的子树满足节点i在第j个位置上的拓扑序列的个数.在求节 ...
- 一、mysql分表简单介绍
一.Mysql分表的原因 1.当一张的数据达到几百万时,你查询一次所花的时间会变多,如果有联合查询的话,我想有可能会死在那儿了. 分表的目的就在于此,减小数据库的负担,缩短查询时间. 2.mysql中 ...
- VS2012/2013编辑器问题
1. Visual Studio 2013 'Could not evaluate Expression' Debugger Abnormality 解决办法:http://weblog.west-w ...
- 合并多个excel工作簿
合并多个Excel工作簿,会出现电话号码以科学计数法显示,如果想要以字符串方式处理,要按如下完整代码 public static void mergeWorkBook() throws Excepti ...
- VSCode
下载: 打开终端控制器 wget http://download.microsoft.com/download/0/D/5/0D57186C-834B-463A-AECB-BC55A8E466AE/V ...