controller包中创建class
package com.cc.springboot.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
public class ProviderController {
@Autowired
JdbcTemplate idbcTemplate;
@GetMapping("/providers")
public Map list(){
List<Map<String, Object>> maps = idbcTemplate.queryForList("select * from provider");
Map<String,Object> map=maps.get(0);
return map;
}
}
List<Map<String, Object>>意思:List集合中的对象是一个Map对象,而这个Map对象的键是String类型,值是Object类型