Skip to content

Conversation

ijaychang
Copy link

按照作者当前的做法,在src/main/resources/mapper目录是必须存在的,启动才能成功。
但我们有些时候,项目比较简单,不需要写XxxMapper.xml这样的文件,而是使用注解的方式如。

package com.company.project.dao;

import com.company.project.core.Mapper;
import com.company.project.model.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface UserMapper extends Mapper<User> {
    @Select("SELECT username FROM user WHERE id = #{id}")
    public String selectUsernameById(@Param("id") Long id);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant