I have a Spring Boot Library package common-library
, within it contains a DTO class, say OrderDTO
[package- com.example.common.dto
].
I have two microservices - Core
& Notification
service. In Core
service I have Order
class in package com.example.core.domain
.
In Notification
service I added common-library
external dependency and created a @FeignClient
class
import com.example.common.dto.OrderDTO;
@FeignClient(name = "core")
public class CoreServiceClient {
@GetMapping("/api/v1/order/get/{id})
OrderDTO getOrderById(@PathVariable("id") String id);
}
Now when I call the getOrderById
method from Notification service, I get the below error
InvalidTypeIdException: "Could not resolve type id 'com.example.core.domain.Order' as a subtype of `com.example.common.dto.OrderDTO`: no such class found"
Now I know one simple way to resolve this issue is by creating match class Order
in package com.example.core.domain
.
But I want to know if there are any workarounds without needing to create same class