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

标签 java spring postman

我是 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/

相关文章:

java - 加载内存Bitmap并共享

java - JButton 更改文本字段的文本颜色

java - Spring 启动: How to pass a command line argument into an annotation value?

java - hibernate HQL查询中获取关系的获取关系

c# - 从 PostMan 调用 asp.net 核心 web api

java - postman 请求编码

java - 如何在父类(super class)构造函数中具有特定条件?

java - 使用正则表达式获取子字符串

java - spring读取xml后如何识别bean需要实现为beanfactory风格还是applicationcontext风格

unit-testing - 我想在同一个测试中运行 post 和 put 方法请求。有什么方法可以让我在 postman 中使用吗?