mybatis.config= # mybatis config file
mybatis.mapperLocations= # mappers file
mybatis.typeAliasesPackage= # domain object's package
mybatis.typeHandlersPackage= # handler's package
mybatis.check-config-location= # check the mybatis configuration exists
mybatis.executorType= # mode of execution. Default is SIMPLE
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.0.2</version>
</dependency>
dependencies {
compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.0.2")
}
Having this mapper
public interface CityMapper {
@Select("SELECT * FROM CITY WHERE state = #{state}")
City findByState(@Param("state") String state);
}
Just create a new Spring Boot Application and let the mapper be injected into it.
@SpringBootApplication
public class SampleMybatisApplication implements CommandLineRunner {
@Autowired
private CityMapper cityMapper;
public static void main(String[] args) {
SpringApplication.run(SampleMybatisApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
System.out.println(this.cityMapper.findByState("CA"));
}
}
That is all!!