1、pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
2、application.properties
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://10.24.73.247:5002/waimai?characterEncoding=utf8
spring.datasource.username=
spring.datasource.password=
3、JdbcTemplate
@RestController
public class DBController {
@Autowired
private JdbcTemplate jdbcTemplate;
@GetMapping("/query")
public Object load() {
String sql = "select * from wm_act_poi_v2 where wm_poi_id = 515";
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql);
return result;
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。