SSM框架中spring的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: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/mvc
 http://www.springframework.org/schema/mvc/spring-mvc.xsd">
 
       <!--开启注解-->
     <context:annotation-config/>
     <mvc:annotation-driven/>
     <!--扫描包-->
     <context:component-scan base-package="com.managerSystem.controller,com.managerSystem.service.impl"/>
     <!--导入数据库包-->
     <context:property-placeholder location="classpath:db.properties"/>
     <!--加载连接池-->
     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
         <property name="driverClassName" value="${mysql.driver}"/>
         <property name="url" value="${mysql.url}"/>
         <property name="username" value="${mysql.user}"/>
         <property name="password" value="${mysql.password}"/>
    </bean>
     <!--整合mybatis-->
     <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
         <property name="dataSource" ref="dataSource"/>
         <property name="mapperLocations" value="classpath:mapper/*mapper-config.xml"/>
     </bean>
    <!--加载sqlSessionFactory-->
     <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
         <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
         <property name="basePackage" value="com.managerSystem.dao"/>
     </bean>
 </beans>

猜你喜欢

转载自blog.csdn.net/qq_33541802/article/details/81540479