从程式码来看,我觉得你最好先去看文件或找本书好好看一一下,
[email protected]@Bean的来源产生器,而@
[email protected],先问一下 a与b变量的注入来源在那里?至于aSet()与bSet()完全不赞同这种写法,@Bean是用来产生注入来源,不是让你用来修一个既有Bean的内容值,若要让Bean有初值,你可以让这个Bean的Bean的内容值,若要让Bean有初值,你可以让这个Bean的class implement InitializingBean或是这样写@Beanpublic A aSet(){A a = new A();a.id="hello";return a;}}
[email protected]写的aSet@Beanpublic Map test(){Map mapTest = new ArrayList<>();mapTest.put('1',aSet()); ....}