emacarron / spring-boot-starter

MyBatis integration with Spring Boot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MyBatis integration with Spring Boot

Build Status Coverage Status Dependency Status Maven central License

Properties file configuration

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

Issue Tracking

GitHub Issues

Maven dependency

<dependency>
	<groupId>org.mybatis.spring.boot</groupId>
	<artifactId>mybatis-spring-boot-starter</artifactId>
	<version>1.0.2</version>
</dependency>

Gradle dependency

dependencies {
    compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.0.2")
}

Simple MyBatis Spring Boot application

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!!

About

MyBatis integration with Spring Boot

License:Apache License 2.0


Languages

Language:Java 77.4%Language:Shell 13.6%Language:Batchfile 9.0%