使用spring在运行时创建javabean
我正在使用spring启动应用程序 当我启动应用程序时 我正在SpringIoC容器中创建bean使用spring在运行时创建javabean,java,spring-boot,Java,Spring Boot,我正在使用spring启动应用程序 当我启动应用程序时 我正在SpringIoC容器中创建bean public class MyBeanCreator{ Object data; @PostConstruct public void getData(){ System.out.println("execute the post-construct first and update the instance variable"); data=MyClass.getDe
public class MyBeanCreator{
Object data;
@PostConstruct
public void getData(){
System.out.println("execute the post-construct first and update the instance variable");
data=MyClass.getDetails();
}
@Bean
public BeanObject beanObject(){
System.out.println("executing the beanObject() method after executing getData() method")
BeanObject obj= new BeanObject();
obj.setBean(obj);
return obj;
}
}
我现在有不同的要求
如何通过传递数据
参数在运行时执行beanObject()
方法
以及如何在运行时创建bean