Bootstrap

Spring的applicationContext.xml配置文件

applicationContext.xml配置文件,包括自动扫描等内容,书写ssm框架是推荐与web.xml,SpringMVC-servlet.xml一起使用。

<?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:aop="http://www.springframework.org/schema/aop"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop " target="_blank">http://www.springframework.org/schema/aop/spring-aop.xsd">

<!--<bean id="users" class="com.nz.service.impl.UserImpl"></bean>-->

<context:property-placeholder location="classpath:com/nz/config/jdbc.properties"></context:property-placeholder>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

<property name="driverClassName" value="${driver}"></property>

<property name="url" value="${url}"></property>

<property name="username" value="${name}"></property>

<property name="password" value="${password}"></property>

</bean>

<!-- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

<property name="dataSource" ref="dataSource"></property>

</bean>

ean id="userDao" class="org.mybatis.spring.mapper.MapperFactoryBean">

<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>

<property name="mapperInterface" value="com.nz.dao.UserD</property>

</bean>

<bean id="users" class="co.service.impl.UserImpl">

<property name="userDao" ref="userDao"></property>

</bean>-->

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

<!--注入数据源-->

<property name="dataSource" ref="dataSource"></property>

<!--加载映射文件-->

<property name="mapperLocations">

<list>

<value>classpath:com/nz/dao/*Mapper.xml</value>

</list>

</property>

<!--实体类 起别名-->

<property name="typeAliasesPackage" value="com.nz.entity"></property>

</bean>

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

<property name="basePackage" value="com.nz.dao"></property>

</bean>

<context:component-scan base-package="com.nz.service"></context:component-scan>

</beans>

;