myBatis配置文件模板

mybatis-config.xml模板如下:


DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <environments default="development">
        <environment id="development">
            
            <transactionManager type="JDBC"/>
            
            <dataSource type="POOLED">
                
                <property name="driver" value="com.mysql.cj.jdbc.Driver"/>
                
                
                
                
                <property name="url" value="jdbc:mysql://localhost:3306/mybatis_?useSSL=true&useUnicode=true&characterEncoding=UTF-8"/>
                <property name="username" value="root"/>
                <property name="password" value="123456"/>
            dataSource>
        environment>
    environments>
    
    <mappers>
        <mapper resource="com/jiu/mapper/PersonMapper.xml"/>
    mappers>
configuration>

mapper.xml如下:


DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.atguigu.mapper.UserMapper">
    
    
    
    
    
    
    
	
    <select id="selectMapById" resultType="map">
        select id,name,age,email from user where id=#{id}
    select>
    <select id="select1" resultType="com.atguigu.pojo.User">
        select id,name,age,email from user where id=#{id}
    select>
mapper>

你可能感兴趣的:(SpringBoot,mybatis)