I'm running two spring boot applications on localhost. They are running on different ports. Let's call them SBA1 (Spring Boot App) and SBA2. There's an end point in SBA2 that I need to use. I already tested it directly on SBA2's swagger UI and I know its working. But when I try to use said end point from SBA1, I can't seem to call it. Here's what I tried so far,
This is the service that calls the class which calls the SBA2's endpoint:
@Service
public class HierarchyServiceImpl implements HierarchyService {
@Autowired
private PolicyRepository service;
//this is the class that calls SBA2's end point
@Autowired
private RuleEngineApi api;
@Override
public Policy calculateCollection(Collection collection) {
Policy policy = service.getPolicyData(collection.getPolicyNumber());
CollectionMapper mapper = new CollectionMapper();
Rule facts = new Rule();
facts.setFacts(mapper.mapCollections(collection, policy));
Rule rule = api.analyzeRules(facts);
return policy;
}
}
This is the class that calls SBA2's endpoint:
@FeignClient(name = "rule-engine-service", url = "http://localhost:8080")
public interface RuleEngineApi {
@PostMapping(value = "/v1/rule/analyzer", consumes = "application/json")
public Rule analyzeRules(Rule rule);
}
The problem with this approach is the application is unable to locate the bean for the RuleEngineApi class. It says this when I try to run SBA1:
required a bean of type '<path of class>.RuleEngineApi' that could not be found.\r\n\r\n\r\nAction:\r\n\r\nConsider defining a bean of type '<path of class>.RuleEngineApi' in your configuration.
I tried something like:
RuleEngineApi api = null;
Rule rule = api.analyzeRules(facts);
But of course that returned a NullPointerException. I would just like to emphasize that SBA2 is working fine. I'm just having trouble calling its endpoint when they (SBA1 and SBA2) are both running locally. Any help would be much appreciated