zoukankan      html  css  js  c++  java
  • ssm整合之配置applicationContext-dao.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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 http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">

    <!-- 配置 读取properties文件 jdbc.properties -->
    <context:property-placeholder location="classpath:jdbc.properties" />



    <!-- 配置 数据源 -->
    <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>

    <!-- 配置SqlSessionFactory -->
    <bean class="org.mybatis.spring.SqlSessionFactoryBean">
    <!-- 设置MyBatis核心配置文件 -->
    <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
    <!-- 设置数据源 -->
    <property name="dataSource" ref="dataSource" />
    </bean>

    <!-- 配置Mapper扫描 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <!-- 设置Mapper扫描包 -->
    <property name="basePackage" value="com.itheima.crm.mapper" />
    </bean>

    <!--jdbc.properties的内容

    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql://localhost:3306/crm-32?characterEncoding=utf-8
    jdbc.username=root
    jdbc.password=123

    -->




    </beans>

  • 相关阅读:
    2月25日
    Maven启动tomcat7:run运行异常:org.apache.catalina.LifecycleException: Failed to start component
    Junit测试报错:java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
    tomcat启动控制台乱码
    Java虚拟机内存详解
    Ajax使用
    Struts2工作流程
    java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
    Spring-Aop的两种代理方式
    springboot与dubbo整合遇到的坑
  • 原文地址:https://www.cnblogs.com/zjj1996/p/9100410.html
Copyright © 2011-2022 走看看