【一】pom文件添加:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version>
</dependency>
【二】application.properties
spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=sa
spring.datasource.password=123
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
【三】创建Mapper和Model(UserMapper和User model)
@Mapper
public interface UserMapper {
@Insert("inser into user(name,accountId,token,gmtCreate,gmtModified) values (#{name},#{accountId},#{token},#{gmtCreate},#{gmtModified})")
void insert(User user);
}
原文:https://www.cnblogs.com/ixtao/p/13923989.html