一个简单的mybatis项目创建基于注解

把IUserDao.xml移除,在dao接口的方法上使用@Select注解,并指定SQL语句,同时需要在mybatis-config.xml中的mapper配置时,使用class属性指定dao接口的全限定类名。
IUserDao.java:

@Select("select * from user")
    List<User> findAll();

mybatis-config.xml:

<mappers>
	<mapper class="net.togogo.dao.IUserDao"></mapper>
</mappers>
发布了31 篇原创文章 · 获赞 1 · 访问量 268

猜你喜欢

转载自blog.csdn.net/weixin_41605945/article/details/104113629