标签:select classpath ppi get app use cat 创建 enc
/** * @author wf.zhang */ @RestController public class HelloController { @Autowired JdbcTemplate jdbcTemplate; @GetMapping("/query") public Map<String, Object> map() { List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from user "); return list.get(0); } }
application.yml
spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/jdbc?useSSL=true&serverTimezone=UTC&characterEncoding=UTF8 data-username: root data-password: root #initialization-mode: always #schema=classpath: schema.sql #schema=classpath: user.sql #data=classpath: data.sql
run 启动类
结果 查询第一个
数据库
查询所有
/** * @author wf.zhang */ @RestController public class HelloController { @Autowired JdbcTemplate jdbcTemplate; @GetMapping("/query") public List<Map<String, Object>> list() { List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from user "); return list; } }
结果
数据库创建表和数据 请看 https://www.cnblogs.com/wf-zhang/p/12163577.html
SpringBoot2.2.2 使用 JdbcTemplate
标签:select classpath ppi get app use cat 创建 enc
原文地址:https://www.cnblogs.com/wf-zhang/p/12164074.html