gpt4 book ai didi

java - Postman 未从 Spring 应用程序获取数据

转载 作者:行者123 更新时间:2023-12-01 17:39:41 25 4
gpt4 key购买 nike

我是 Spring 的新手。我的 Spring 应用程序已启动并正在运行。但是当我使用 postman 来获取数据时。它抛出 404 未找到错误。我检查了 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

帮助我

最佳答案

对于上面的 postman 图像,您使用的是 5556 端口。默认情况下,Spring Boot 使用 8080 端口号。但是,您可以在属性文件中更改正在运行的端口。在 Spring Boot 中,属性保存在类路径下的 application.properties 文件中。 application.properties 文件位于 src/main/resources 目录中。

[https://www.tutorialspoint.com/spring_boot/spring_boot_application_properties.htm][1]

[1]:Spring Boot

关于java - Postman 未从 Spring 应用程序获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60978111/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com