spring中通过properties文件配置数据源
来源:互联网 发布:java软件设计大赛 编辑:程序博客网 时间:2024/05/14 02:29
jdbc.properties文件:
#driver= oracle.jdbc.driver.OracleDriverdriver=com.mysql.jdbc.Driver#url=jdbc:oracle:thin:@127.0.0.1:1521:testurl=jdbc:mysql://127.0.0.1:3306/testusername=rootpassword=12345
方法一:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:property-placeholder location="classpath:jdbc.properties"/> <!--<context:component-scan base-package="com"></context:component-scan> --> <bean id="dataSource_1" class="org.logicalcobwebs.proxool.ProxoolDataSource" > <property name="driver" value="${driver}"/> <property name="driverUrl" value="${url}"/> <property name="user" value="${username}"/> <property name="password" value="${password}" /> <property name="maximumActiveTime" value="${maximumActiveTime}" /> </bean > <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" > <property name="driver" value="${driver}"/> <property name="driverUrl" value="${url}"/> <property name="user" value="${username}"/> <property name="password" value="${password}"/> <property name="maximumConnectionCount" value="200" ></property> </bean>
方法二:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!--配置数据源属性文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>/WEB-INF/configs/sqlServer.properties</value> </property> </bean> <!--配置数据源 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>${jdbc.driver}</value> </property> <property name="url" > <value>${jdbc.url}</value> </property> <property name="username" > <value>${jdbc.user}</value> </property> <property name="password"> <value>${jdbc.pwd}</value> </property> </bean>
阅读全文
0 0
- spring中通过properties文件配置数据源
- Spring通过.properties文件引入属性配置
- Java中通过Spring读取Properties文件
- 基于maven管理的项目中spring+mybatis配置数据源读取不到properties属性文件的问题
- spring配置文件中配置jdbc.properties 文件
- 通过Spring配置JNDI数据源
- Spring 配置数据源及properties配置文件加载
- AAA java向xml文件传值是通过属性properties进行的 spring + mybatis 动态切换数据源
- java 用properties文件配置spring数据源,用spring的JdbcTemplate的queryForList查数据
- java 用properties文件配置spring数据源,用spring的JdbcTemplate的queryForList查数据
- Spring中配置数据源
- spring中配置数据源
- Spring中配置数据源
- spring中数据源配置
- spring中配置数据源
- Spring中数据源配置
- Spring中数据源配置
- Spring中配置数据源
- 登录注册、在微信小程序中是怎么修改button样式的?
- Codeforces 825F String Compression DP(最小循环节)
- NOIP2017模拟(7.17)
- (sgu)Balloons(记忆化搜索)
- Unity3d 技巧(5) 了解VR 游戏开发 美术和资源规范
- spring中通过properties文件配置数据源
- 神经网络入门之bp算法,梯度下降
- Redis字符串类型命令介绍(二)
- MySQL单表百万数据记录分页性能优化
- 根据时间戳计算年龄
- 【漏洞预警】FFmpeg曝任意文件读取漏洞
- codeforces GYM 101431D(构造)
- 傻牛的递推数列(数论,斐波那契)
- 欢迎使用CSDN-markdown编辑器