我的基本 Spring Boot 应用程序在所有端点上仅返回 404,我无法弄清楚为什么
主要文件
@SpringBootApplication
@EnableJpaRepositories("com.employee.*")
@ComponentScan(basePackages = { "com.employee.*" })
@EntityScan("com.employee.*")
public class EmployeeApplication {
public static void main(String[] args) {
SpringApplication.run(EmployeeApplication.class, args);
}
EmployeeController.java
@RestController
@RequestMapping("/employees")
public class EmployeeController {
@Autowired
private EmployeeService employeeService;
@GetMapping("/healthcheck")
public String healthCheck() {
return "success";
}
@GetMapping("/all")
public ResponseEntity<List<Employee>> getAllEmployees() {
List<Employee> employees = employeeService.getAllEmployees();
return new ResponseEntity<>(employees, HttpStatus.OK);
}
服务器启动正常,没有问题,日志中没有错误,但无论我尝试点击什么网址,无论是 http://localhost:8080/employees/healthcheck 还是 http://localhost:8080/employees/all,它们都会返回 404 .不知道我在这里缺少什么
我认为它将成功字符串识别为模板并且无法解析 success.html?