spring mybatis整合读取配置文件
来源:互联网 发布:windows窗口编程 编辑:程序博客网 时间:2024/05/16 01:55
第一种:采用$符读取配置文件中的内容
<?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:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/task http://www.springframework.org/schema/task/spring-task-3.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"
<!-- 系统环境变量定义 --> <context:property-placeholder location="classpath:conf.properties" ignore-unresolvable="true" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" parent="parentdataSource"> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /></bean>
此方式自动装配方式不能是byName,会出现读取不到配置文件中内容的情况第二种:采用#方式读取配置文件中的内容
<?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:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/task http://www.springframework.org/schema/task/spring-task-3.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd" default-autowire="byName"> <!-- 系统环境变量定义 --> <context:property-placeholder location="classpath:conf.properties" ignore-unresolvable="true" /> <util:properties id="properties" location="classpath:conf.properties"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" parent="parentdataSource"> <property name="url" value="#{properties['jdbc.url']}" /> <property name="username" value="#{properties['jdbc.username']}" /> <property name="password" value="#{properties['jdbc.password']}" /></bean>
0 0
- spring mybatis整合读取配置文件
- spring+mybatis整合读取不了配置文件
- spring-mybatis整合(配置文件)
- mybatis整合spring配置文件
- 关于Spring与mybatis整合无法读取配置文件的问题
- Spring+Mybatis整合读取Jar中的mapper配置文件
- Spring与Mybatis整合配置文件
- struts2 + spring + mybatis 整合配置文件
- spring与mybatis整合配置文件
- mybatis与spring整合配置文件
- spring+springmvc+mybatis整合配置文件
- spring整合mybatis的配置文件
- spring boot mybatis 读取配置文件
- spring boot mybatis 读取配置文件
- Spring、Spring MVC、Mybatis整合配置文件详解
- 解决整合spring和mybatis后数据源配置文件读取错误,错误提示数据库用户名密码错误。
- mybatis与spring整合(基于配置文件)
- mybatis与spring整合(基于配置文件)
- java的concurrent用法详解
- 英文邮件礼仪:向教授请教学术问题
- USB
- java作业之输出1-100只能能被3整除的前5个整数。。。
- 【CentOS 7】Virtual Console 更改字体及大小
- spring mybatis整合读取配置文件
- Activity之间使用intent传递大量数据带来问题总结
- 个人所得税计算器
- 将webview的内容转换成pdf输出
- mac系统命令行curl详解
- Android 用ping来判断网络是否可用
- 剑指offer 二叉搜索树的后序遍历序列
- (4.5.3.1)AndroidStudio用gradle编译中文乱码
- 这个函数可以辅助向现有URL 的末尾添加查询字符串参数