I have two rest controllers on the same package level with following code:
First controller:
@RequestMapping(API + NO_AUTH + "/payments/method")
public class PaymentMethodController {
private final PaymentMethodService paymentMethodService;
@GetMapping("/{parentId}/{schoolId}/all")
public List<PaymentMethod> getAllCardsForParent(
@PathVariable final Long parentId, @PathVariable final Long schoolId) {
return paymentMethodService.getPaymentMethodCards(parentId, schoolId);
@PostMapping("/{parentId}/{schoolId}")
public SetupPaymentMethodResponse generateSetupToken(
@PathVariable final Long parentId, @PathVariable final Long schoolId) {
return paymentMethodService.createPaymentMethodSetupToken(parentId, schoolId);
<code>
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping(API + NO_AUTH + "/payments/method")
public class PaymentMethodController {
private final PaymentMethodService paymentMethodService;
@GetMapping("/{parentId}/{schoolId}/all")
public List<PaymentMethod> getAllCardsForParent(
@PathVariable final Long parentId, @PathVariable final Long schoolId) {
return paymentMethodService.getPaymentMethodCards(parentId, schoolId);
}
@PostMapping("/{parentId}/{schoolId}")
public SetupPaymentMethodResponse generateSetupToken(
@PathVariable final Long parentId, @PathVariable final Long schoolId) {
return paymentMethodService.createPaymentMethodSetupToken(parentId, schoolId);
}
}
</code>
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping(API + NO_AUTH + "/payments/method")
public class PaymentMethodController {
private final PaymentMethodService paymentMethodService;
@GetMapping("/{parentId}/{schoolId}/all")
public List<PaymentMethod> getAllCardsForParent(
@PathVariable final Long parentId, @PathVariable final Long schoolId) {
return paymentMethodService.getPaymentMethodCards(parentId, schoolId);
}
@PostMapping("/{parentId}/{schoolId}")
public SetupPaymentMethodResponse generateSetupToken(
@PathVariable final Long parentId, @PathVariable final Long schoolId) {
return paymentMethodService.createPaymentMethodSetupToken(parentId, schoolId);
}
}
Second controller
@RequestMapping(API + NO_AUTH + "/payments")
public class PaymentController {
private final CapturePaymentService capturePaymentService;
public CapturePaymentResponse createPaymentForActivity(
@RequestBody final CapturePaymentRequest capturePaymentRequest) {
return capturePaymentService.createPayment(capturePaymentRequest);
@PostMapping("/{paymentId}/confirm")
public void capturePayment(@PathVariable Long paymentId) {
capturePaymentService.captureSubscription(paymentId);
<code>
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping(API + NO_AUTH + "/payments")
public class PaymentController {
private final CapturePaymentService capturePaymentService;
@PostMapping("/create")
public CapturePaymentResponse createPaymentForActivity(
@RequestBody final CapturePaymentRequest capturePaymentRequest) {
return capturePaymentService.createPayment(capturePaymentRequest);
}
@PostMapping("/{paymentId}/confirm")
public void capturePayment(@PathVariable Long paymentId) {
capturePaymentService.captureSubscription(paymentId);
}
}
</code>
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping(API + NO_AUTH + "/payments")
public class PaymentController {
private final CapturePaymentService capturePaymentService;
@PostMapping("/create")
public CapturePaymentResponse createPaymentForActivity(
@RequestBody final CapturePaymentRequest capturePaymentRequest) {
return capturePaymentService.createPayment(capturePaymentRequest);
}
@PostMapping("/{paymentId}/confirm")
public void capturePayment(@PathVariable Long paymentId) {
capturePaymentService.captureSubscription(paymentId);
}
}
Both the controllers are at same package level. I am able to hit the PaymentMethodController
but I am not able to hit PaymentController
.
ApplicationStarter i.e. SpringBoot main class is at the root of the project.
I think the URI might be conflicting but I am not sure why this issue is happening.
I can run this on local as well and I am able to hit both controller but after deployment it is not working for PaymentController
.