Spring 專案中applicationContext.xml模板
阿新 • • 發佈:2018-12-13
<?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:p="http://www.springframework.org/schema/p" 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-4.3.xsd"> <context:component-scan base-package="要掃描的包名:例:com.test.dao"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" /> <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository" /> </context:component-scan> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" p:driverClassName="com.mysql.cj.jdbc.Driver" p:url="jdbc:mysql:///db_sell?serverTimezone=UTC" p:username="root" p:password="root"></bean> <bean id="jt" class="org.springframework.jdbc.core.JdbcTemplate" p:dataSource-ref="dataSource"></bean> </beans>