I have defined a Bean like this in a Spring-boot Configuration(annotated with @Configuration) class :
@Bean
public MyRegistry myRegistry() {
return new MyRegistry();
}
MyRegistry looks like this :
@Component
@Getter
@Setter
public class MyRegistry {
Map<String, Object> resourcesMap = new HashMap<>();
public MyRegistry() {
resourcesMap.put("handler1", new MyHandler1());
resourcesMap.put("handler2", new MyHandler2());
}
}
Now, in another class with @Component, I have @Autowired myRegistry and using it as below :
MyHandler1 handler1 = new ObjectMapper().convertValue(myRegistry.getResourcesMap().get("handler1"), MyHandler1.class);
I do not get any error while starting the Spring-Boot application, but when the application running, methods of Handler1 is not accessible.
Want to understand what am I doing wrong here. I probably am messing up annotation usage as I am new to Spring-Boot
MyRegistry
? That's usually the job that Spring does for you. – chrylis -cautiouslyoptimistic-