【问题标题】:Postman is not fetching data from spring application邮递员没有从 Spring 应用程序中获取数据
【发布时间】: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 上运行

标签: java spring postman


【解决方案1】:

关于上面的邮递员图像,您使用的是 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]: 春季启动

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-16
    • 2022-08-03
    • 2015-06-08
    • 2013-10-14
    • 2020-07-01
    • 2014-10-06
    • 1970-01-01
    • 2023-03-23
    相关资源
    最近更新 更多