SpringBoot+Spring+Mybatis项目
https://start.spring.io/
连接打通数据库配置
spring.datasource.driver-class-name =com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=root
#开启控制台打印sql
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
Step1:实体对象
public class UserTest {
private String username;
}
Step2:Dao层连接数据库
public interface UserTestMapper{
@Insert("insert into user_test1(username) values(#{username})")
int save(UserTest userTest);
}
Step3:Service
public interface UserService {
int save(UserTest u