【发布时间】:2020-04-01 18:44:03
【问题描述】:
我是春天的新手。 我的 Spring 应用程序已启动并正在运行。但是当我使用邮递员来获取数据时。它抛出 404 not found 错误。我检查了 URL,但我没有找到错误的地方。 谁能帮我。 这是我的 API 类
@RestController
@RequestMapping(value="/nicetry")
public class NiceAPI {
@Autowired
private NiceService niceService;
@GetMapping(value = "/student")
public ResponseEntity<List<Student>> getDetails(){
List<Student> studentList= niceService.getDetails();
ResponseEntity<List<Student>> response = new ResponseEntity<List<Student>>
(studentList,HttpStatus.OK);
return response;
}
}
Here is the Postman Screen image
这是应用程序控制台
2020-04-01 23:50:24.207 WARN 8400 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view
rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-04-01 23:50:24.704 INFO 8400 --- [ main]
o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService
'applicationTaskExecutor'
2020-04-01 23:50:25.458 INFO 8400 --- [ main]
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 5556
(http) with context path ''
2020-04-01 23:50:25.495 INFO 8400 --- [ main]
com.saif.NiceTry.NiceTryApplication : Started NiceTryApplication in
44.685 seconds (JVM running for 55.867)
2020-04-01 23:52:02.858 INFO 8400 --- [nio-5556-exec-2] o.a.c.c.C.[Tomcat].
[localhost].[/] : Initializing Spring DispatcherServlet
'dispatcherServlet'
2020-04-01 23:52:02.858 INFO 8400 --- [nio-5556-exec-2]
o.s.web.servlet.DispatcherServlet : Initializing Servlet
'dispatcherServlet'
2020-04-01 23:52:03.276 INFO 8400 --- [nio-5556-exec-2]
o.s.web.servlet.DispatcherServlet : Completed initialization in 417 ms
帮帮我
【问题讨论】:
-
您确定您的应用程序在 5556 端口上运行吗?您是否在属性文件中设置了任何上下文路径?
-
是的,我确定应用程序正在端口 5556 上运行