集成MyBaits

1. 使用SpringBoot的starter引入相关的依赖

版本最好对应SpringBoot的版本

        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            2.1.0
        
        

2. 设置扫描的包位置

Application进行设置

@SpringBootApplication
@MapperScan("me.tinuv.myproject.dao")
public class MyProjectApplication extends SpringBootServletInitializer {


    public static void main(String[] args) {
        SpringApplication.run(MyProjectApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(MyProjectApplication.class);
    }
}

3. 使用注解使用MyBaits

@Repository
@Mapper
public interface PermissionMapper {


    @Select("select id,permission,permission_describe as permissionDescribe from permission where id=#{id}")
    Permission findPermissionById(@Param("id") long id);
    
    
}
??正文结束??

你可能感兴趣的:(集成MyBaits)