Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Webflux returns 404 ( Not Foud )

I have to save some values in a reactive way using spring Webflux. But when I send the request then 404 status is returned as a response.

pom.xml

 <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-jersey</artifactId>
 </dependency>
 <dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-webflux</artifactId>
 </dependency>

EmpController class

@RestController
@RequestMapping("/emp")
public class EmpController {

    private EmployeeRepository empRepo;

    @Autowired
    public EmpController(EmployeeRepository empRepo)
    {
        this.empRepo=empRepo;
    }

    @PostMapping("/save")
    @Consumes({MediaType.APPLICATION_JSON})
    public void saveEmp(@RequestBody Mono<Employee> emp)
    {
             emp.subscribe(e-> {
                 e.setDate(new Date());
                 empRepo.saveEmp(e);
             });
    }
}

When I send the request via PostMan then 404(not found) is returned.

enter image description here enter image description here

like image 905
NafazBenzema Avatar asked Oct 28 '25 17:10

NafazBenzema


1 Answers

I had the same problem. The solution:

  1. go to application.properties,
  2. remove server.servlet.context-path
  3. and add spring.webflux.base-path
like image 137
Kirill Parfenov Avatar answered Oct 30 '25 06:10

Kirill Parfenov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!