springboot中添加注解扫描DAO层
1、在dao层的接口上加上@Mapper注解
@Mapper
public interface UserDao {
@Insert("insert into tb_user (id,username,password) values (#{id},#{username},#{password})")
int addUser(User user);
}
2、在启动类上加上@MapperScan(“dao层路径”)
@SpringBootApplication
@MapperScan("it.gm.springboot_project01.dao")
public class SpringbootProject01Application {
public static void main(String[] args) {
SpringApplication.run(SpringbootProject01Application.class, args);
}
}
版权声明:本文为z7kirictol原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。