1.启动类
@SpringBootApplication
@ComponentScan(basePackages={
"com.dsf"})
public class ApplicationBootControler {
public static void main(String[] args) {
SpringApplication.run(ApplicationBootControler.class, args);
}
}
2.获取数据类
@Component
public class WeiBoDBManager {
@Autowired
private JdbcTemplate jdbcTemplate;
public JSONObject getSourceHotData() {
String sql = "select source,score from statistic_source_hot limit 6";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
JSONObject jsonObj = new JSONObject();
JSONArray xArray = new JSONArray();
JSONArray yArray = new JSONArray();
for (Map<String, Object> map : list) {
Object source = map.get("source");
Object score = map.get("score");
xArray.add(source);