此处地址栏为 localhost:8080
此处地址栏为 服务器ip:8080
package net.suncaper.epidemicdataanalysis.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/uv")
public class ChinaDayController {
@Autowired
private JdbcTemplate jdbcTemplate;
@GetMapping("chinaData")
@ResponseBody
public List<Map<String, Object>> listUvCovid(){
//中国每日各省份数据
String sql = "select * from chn_data_per_province_by_date";
return jdbcTemplate.queryForList(sql);
}
@GetMapping("chinaCure")
@ResponseBody
public List<Map<String, Object>> listCure(){
//中国每日各省份数据
String sql = "select * from chn_cure_rate_per_province";
return jdbcTemplate.queryForList(sql);
}
@GetMapping("chinaDeath")
@ResponseBody
public List<Map<String, Object>> listDeath(){
//中国每日各省份数据
String sql = "select * from chn_death_rate_per_province";
return jdbcTemplate.queryForList(sql);
}
@GetMapping("chinaLineChart")
@ResponseBody
public List<Map<String, Object>> listLineChart(){
String sql = "select * from china_line_chart";
return jdbcTemplate.queryForList(sql);
}
}
package net.suncaper.epidemicdataanalysis;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class EpidemicDataAnalysisApplication {
public static void main(String[] args) {
SpringApplication.run(EpidemicDataAnalysisApplication.class, args);
}
}
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
404是找不到页面,也就是说跟你前端的资源文件有关 html/js/css这些资源文件
打包的pom.xml的插件有问题,没有把资源文件加载进去
这是你接口没访问到404,不是数据库没连到
如果是前后端不分离的话,应该是你打包的时候前端文件没打包进去。
漂亮,截图完美的避开了404最需要查看的浏览器地址栏