Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用spring在运行时创建javabean_Java_Spring Boot - Fatal编程技术网

使用spring在运行时创建javabean

使用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

我正在使用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.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