为什么mapper包引入失败呀?
mapper接口
package com.benchuat.mapper;
import com.benchuat.pojo.User;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserMapper {
int insertUser(String name, int age);
int deleteUserbyId(int id);
int updateUserbyId(int id, String name, int age);
User selectUserbyId(int id);
}
mybatis.xml
xml version="1.0" encoding="UTF-8" ?>
configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties resource="application.properties">properties>
<typeAliases>
<package name="com.benchuat.pojo"/>
typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="${spring.datasource.driver-class-name}"/>
<property name="url" value="${spring.datasource.url}"/>
<property name="username" value="${spring.datasource.username}"/>
<property name="password" value="${spring.datasource.password}"/>
dataSource>
environment>
environments>
<mappers>
<package name="com.benchuat.mapper"/>
mappers>
configuration>
测试方法
@Test
public void userTest() {
Connation connation = new Connation();
SqlSession session = connation.getSession();
User user = session.selectOne("com.benchuat.mapper.UserMapper.selectUserbyId", 1);
System.out.println(user);
connation.closeSession(session);
}
目录
使用资源导入没有问题
使用包导入就不行