1

This is an example done in J2EE application, I am looking for an exact solution for this in Spring Boot.

path: localhost:8080/first/second/get-this
Output: Here You Go!

//First Resource
@Path("first")
@RequestScoped
public class FirstResource {

@Inject
SecondResource secondResource;

@Path("second")
public SecondResource getSecondResource() {
    return secondResource;
    }
}

//Second Resource
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)   
public class SecondResource {

@Path("get-this")
@GET
@Produces(MediaType.APPLICATION_JSON)
public void getThisMessage(){
System.out.println("Here You Go!");    
} 

1 Answers1

3

Sub-resources is a feature of JAX-RS, an API from JavaEE/JakartaEE. There is no sub-resources or any equivalent feature in Spring MVC or Spring WebFlux APIs. What you could do is create the Rest controllers using Jersey inside Spring, Jersey is the reference implementation for JAX-RS so it supports sub-resources.

Rafael Guillen
  • 1,343
  • 10
  • 25