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

版本最好对应SpringBoot的版本

        <!-- MyBaits -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.0</version>
        </dependency>
        <!-- MyBaits -->

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);
    
    
}
🌹💗正文结束💗🌹