db.properties jdbc.driver=com.oracle.jdbc.OracleDriver jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:wiicare jdbc.username=wiicare jdbc.password=Mdsd123 log4j.properties### 设置### log4j.rootLogger = ERROR,stdout ### è¾åºä¿¡æ¯å°æ§å¶æ¬ ### log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n log4j.category.org.springframework.beans.factory=ERROR mybatis-config.xml<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <configutation> <!-- 引入数据库配置 --> <properties resource="db.properties"></properties> <!-- 定义别名 --> <typeAliases> <typeAlias type="com.geyao.mybatis.pojo.Blog" alias="Blog"></typeAlias> </typeAliases> <!-- 定义数据源 --> <environments default=""> <environment id="development"> <dataSource type="POOLED"> <property name="driver" value="${jdbc.driver}"></property> <property name="url" value="${jdbc.url}"></property> <property name="username" value="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"></property> </dataSource> </environment> </environments> <mappers> <package name="com.geyao.mabatis.mapper"></package> </mappers> </configutation> BlogMapper.xml<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.geyao.mybatis.mapper.BlogMapper"> <!-- statement --> <select id="selectBlog" parameterType="int" resultType="Blog"> select * from Blog where id=#{id} </select> </mapper> BlogMapper类package com.geyao.mybatis.mapper; import com.geyao.mybatis.pojo.Blog; public interface BlogMapper { Blog selectBlog(Integer id); } Blog类package com.geyao.mybatis.pojo; public class Blog { }