JAVA模板
application.yml
spring:
profiles:
active: dev
application-dev.yml
server: port: 8088 spring: datasource: username: root password: Chen6218 url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC driver-class-name: com.mysql.cj.jdbc.Driver mybatis: mapper-locations: classpath:mapper/*Mapper.xml type-aliases-package: com.chentemplate.entity #showSql logging: level: com: example: mapper : debug
UserMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>insert into User (id,name,age) values( #{id},#{name},#{age},) delete from User where id=#{id}
IUserDao
package com.chentemplate.dao; import com.chentemplate.entity.User; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; import java.util.List; @Mapper @Repository public interface IUserDao{ ListfindAll(); }
controller
@RestController public class Test { @Resource IUserDao iUserDao; @GetMapping("/say") public Listsay() { return iUserDao.findAll(); } }