How to inject an object to Spring IoC through ApplicationContext? I want to put an POJO Object with some infomation to IoC Container through instand of writing a method and sign annotation @bean I try this way but fail
@Autowired
ApplicationContext context;
@Test
void contextLoads() {
GenericWebApplicationContext genericWebApplicationContext = (GenericWebApplicationContext) context;
genericWebApplicationContext.registerBean(Book.class, XXX);
}
because registerBean need arguement Class and constructorArgs,i don`t want to just for inject an object to container to create a construct method. just want to inject an existing Object (may i create in a method) to container,not using @bean
question from:https://stackoverflow.com/questions/65651215/how-to-inject-an-object-to-spring-ioc-container-through-applicationcontext