1

I have an application which exposes multiple endpoints. example:

v1/transaction/spectra 
v1/transaction/jupiter 
v2/payment/blaze

Here is the definition of Application URI

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/v1")
@Component
public class ApplicationConfig extends Application {

}

@Path("/transaction")
public interface SpectrAPI {
    
    @POST
    @Path("/spectra")
    Response evaluatePlanningDecisions(final Request request); 
 
}

@Path("/transaction")
public interface JupiterAPI {
    
    @POST
    @Path("/jupiter")
    Response evaluatePlanningDecisions(final Request request); 
 
}


 

As the application supports different URL's as shown below

v1/transaction , v2/payment

How would @ApplicationPath support multiple resourses (v1/v2)?

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
mitali
  • 87
  • 8
  • 1
    Perhaps `@ApplicationPath("/")` and having the version in resource paths? That doesn't seem right to me though, so I might just create two `Application` classes, one for each version. – ernest_k Oct 16 '21 at 21:02
  • maybe you can read this https://stackoverflow.com/questions/20198275/how-to-manage-rest-api-versioning-with-spring – Murat Kara Oct 16 '21 at 22:51
  • @ernest_k When I start the server, all the requests are getting redirected to V2. any reasons? – mitali Oct 19 '21 at 00:09
  • @mitali With the current setup? Or did you change it? Also, how are you `Application` classes discovered? Is your jax-rs implementation scanning annotations? Or are you using web.xml config? – ernest_k Oct 19 '21 at 04:47

0 Answers0