可以从Jar外部加载JDBC.properties的Spring-mybatis配置文件
2018-03-07 17:29
399 查看
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <context:annotation-config/> <context:component-scan base-package="com.jiuzhou.crawler"/> <!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="file:#{systemProperties['user.dir']}/conf/jdbc.properties"/> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> <!-- 初始化连接大小 --> <property name="initialSize" value="${jdbc.initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${jdbc.maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${jdbc.maxIdle}"></property> <!-- 连接池最小空闲--> <property name="minIdle" value="${jdbc.minIdle}"></property> <!-- 获取连接最大等待时间--> <property name="maxWait" value="${jdbc.maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath*:com/jiuzhou/crawler/*/sqlxml/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.jiuzhou.crawler.*.mapper"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> </beans>
相关文章推荐
- 可以从Jar外部加载JDBC.properties的Spring-mybatis配置文件
- Spring+mybatis+maven整合过程加载配置文件jdbc.properties
- spring (三) 加载外部资源文件/配置jdbc数据源
- For input string: "${JDBC.MinPoolSize}" spring加载jdbc.properties配置文件报错
- Spring配置中从外部文件加载多个properties文件
- 让spring的配置文件可以使用外部properties里的参数。
- Spring加载配置文件--jdbc.propertities
- Spring配置文件加载properties文件
- spring加载properties配置文件
- SqlMapConfig.xml --- 在spring配置文件中自动加载的mybatis文件
- Spring使用配置文件读取jdbc.properties
- JdbcTemplae使用入门&&Spring三种连接池配置&&Spring配置文件引用外部properties文件
- Spring 使用配置文件读取jdbc.properties
- spring+mybatis+druid无法读取jdbc.properties属性导致datasource加载失败
- spring加载jar包中多个配置文件
- 详解Spring Boot加载properties和yml配置文件
- spring和mybatis整合加载jdbc.properties异常
- spring boot:使用@ConfigurationProperties注解加载配置文件
- MyBatis之全局配置文件(Configuration XML)之引入外部配置文件(properties)
- Spring+mybatis加载外部文件时加载失败问题