ssm配置复制粘贴用

applicationContext-Dao:

xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans" 
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop" 
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd 
                            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd 
                            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
                            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">

<context:property-placeholder location="classpath:db.properties"/>


<bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
    <property name="driverClassName" value="${jdbc.driverClass}">property>
    <property name="url" value="${jdbc.jdbcUrl}">property>
    <property name="username" value="${jdbc.user}">property>
    <property name="password" value="${jdbc.password}">property>
bean>


<bean name="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    
    <property name="dataSource" ref="dataSource">property>
    
    <property name="configLocation" value="classpath:sqlMapConfig.xml">property>
bean>


<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    
    <property name="basePackage" value="cn.itheima.mapper">property>
bean>

beans>

 

springmvc.xml:

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


<context:component-scan base-package="cn.itheima.controller"/>



<mvc:annotation-driven/>


<bean name="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    
    
bean>


beans>

 

sqlMapConfig.xml:

xml version="1.0" encoding="UTF-8"?>
DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis/dtd/mybatis-3-config.dtd">

<configuration>



    <typeAliases>
        <package name="cn.itheima.pojo"/>
    typeAliases>
    

    
configuration>

 

mapper.xml:

xml version="1.0" encoding="UTF-8"?>
DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis/dtd/mybatis-3-mapper.dtd">

 

db.properties:

jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl=jdbc:mysql:///xxx
jdbc.user=root
jdbc.password=123

 

你可能感兴趣的:(ssm配置复制粘贴用)