[spring] spring-dao层配置文件

搭配使用
service层配置文件(applicationContext-service.xml):
https://blog.csdn.net/a755199443/article/details/90272977

事务管理配置文件(applicationContext-trans.xml):
https://blog.csdn.net/a755199443/article/details/90273049

dao层配置文件主要做数据库相关的配置.
文件名:applicationContext-dao.xml


<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:aop="http://www.springframework.org/schema/aop"
	   xmlns:tx="http://www.springframework.org/schema/tx"
	   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:property-placeholder location="classpath:db.properties"/>

	
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass" value="${jdbc.driver}"/>
		<property name="jdbcUrl" value="${jdbc.url}"/>
		<property name="user" value="${jdbc.username}"/>
		<property name="password" value="${jdbc.password}"/>
	bean>

	
	
	
	
	
	
	
	
	

	
	<bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
		<property name="dataSource" ref="dataSource"/>
		<property name="configLocation" value="classpath:SqlMapperClient.xml"/>
		<property name="typeAliasesPackage" value="com.csdn.pojo" />
	bean>
	
	


		<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
			<property name="basePackage" value="com.csdn.mapper"/>
			
		bean>

beans>

附上properties文件:

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mysql505?characterEncoding=utf-8
jdbc.username=root
jdbc.password=root

你可能感兴趣的:(配置文件,配置文件整理)