@Configuration
public class ComponentTest {
@Bean
public String test(){
return new String("123");
}
@Bean
public String test2(){
return test();
}
}
Test:
public class ComponentBeanTest extends BaseTest{
@Resource
String test;
@Resource
String test2;
@Test
public void test() {
System.out.println(test);
System.out.println(test2);
System.out.println(test == test2);
}
}
输出:
123
123
true
@Component
public class ComponentTest {
@Bean
public String test(){
return new String("123");
}
@Bean
public String test2(){
return test();
}
}
Test和@Configuration注解的相同
输出:
123
123
false