Spring 项目中模板

时间:2025-03-20 07:14:08
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="/schema/beans"
	xmlns:xsi="http:///2001/XMLSchema-instance"
	xmlns:context="/schema/context"
	xmlns:jdbc="/schema/jdbc"
	xmlns:p="/schema/p"
	xmlns:tx="/schema/tx"
	xsi:schemaLocation="/schema/jdbc /schema/jdbc/spring-jdbc-4.
		/schema/beans /schema/beans/
		/schema/context /schema/context/spring-context-4.
		/schema/tx /schema/tx/spring-tx-4.">

	<!-- 数据库连接信息的配置文件 -->
	<context:property-placeholder
		location="classpath:" />
		
		
	<!-- 数据库连接池 -->
	<bean 
		class=""
		p:driverClassName="${}" p:url="${}"
		p:username="${}" p:password="${}"
		destroy-method="close" />

	<!-- 引入事务的配置 -->
	<tx:annotation-driven
		transaction-manager="transactionManager" />
	<bean 
		class=""
		p:dataSource-ref="dataSource"></bean>

	<!-- 整合 mybatis -->
	<bean 
		class=""
		p:dataSource-ref="dataSource"
		p:mapperLocations="classpath:com/lanou/mapper/*.xml" />

	<!-- 初始化数据库,是否在服务启动时执行 -->
	<jdbc:initialize-database enabled="false">
		<jdbc:script location="classpath:database/" />
	</jdbc:initialize-database>

	<!--  mybatis自动扫描 将Mapper接口生成代理注入到Spring -->
	<bean class=""
		p:sqlSessionFactoryBeanName="sqlSessionFactory"
		p:basePackage="" />

	<!-- spring自动扫描:扫描用Service,和Repository注解申明的受管bean -->
	<context:component-scan
		base-package="">
		<context:include-filter type="annotation"
			expression="" />
	</context:component-scan>
	<context:component-scan
		base-package="">
		<context:include-filter type="annotation"
			expression="" />
	</context:component-scan>
</beans>