zoukankan      html  css  js  c++  java
  • 记录下配置

    <?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"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    https://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    https://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/tx
    https://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop
    https://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/mvc
    https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    静态
    <mvc:default-servlet-handler/>
    <!--其他就走其他咯-->
    <mvc:annotation-driven/>
    扫描位置 加上这句 use-default-filters="false" 就只包含我要包含的了 那还不如我指定下一级

    <context:component-scan base-package="com.itheima.controller  >
    </context:component-scan>
    <!--加载配置文件-->
    <context:property-placeholder location="classpath:*.properties"/>
    <!--扫描包-->
    <context:component-scan base-package="com.itheima">
    排除mvc的bean
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

    <!--数据源-->

    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
    <property name="driverClassName" value="${jdbc.driver}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
    </bean>
    数据库相关

    <bean class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="typeAliasesPackage" value="com.itheima.domain"/>
    </bean>
    dao层的东西
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.itheima.dao"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
    </bean>

    <tx:annotation-driven/>
    <!--扫描加载所有的控制类类-->

    <!--<mvc:resources mapping="/img/**" location="/img/"/>-->




    <!--
    如果是自己写的bean,用注解
    如果是第三方的bean,用配置文件
    -->

    </beans>
  • 相关阅读:
    Spring框架构造注入的属性问题type属性
    Spring框架AOP添加日志记录功能
    Spring框架构造注入
    Spring框架AOP原理
    Spring框架构造注入的顺序问题index属性
    Spring框架使用P命名空间进行注入
    工作中的SQL脚本
    spring框架ioc设置注入小demo
    [笔试] C和C++动态内存分配和释放的区别
    [算法] 当今世界最为经典的十大算法投票进行时
  • 原文地址:https://www.cnblogs.com/KingAndPig/p/13822597.html
Copyright © 2011-2022 走看看