21
SampleBean:@PostConstruct方法,並沒有所謂的春季
package com.springexample;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
public class SampleBean {
private BeanTypeOne beanOne;
private BeanTypeTwo beanTwo;
public void init() {
System.out.println("This is from the init() method");
}
@PostConstruct
public void initAnnotation() {
System.out.println("This is from the initAnnotation() method");
}
和配置文件是這樣的:
<bean id="SampleBean" class="com.springexample.SampleBean">
<property name="beanOne" ref="beanOneOne"></property>
<property name="beanTwo" ref="beanTwoOne"></property>
</bean>
而且我也沒有默認初始化方法屬性設置豆標籤。
任何機構都可以告訴爲什麼@PostConstruct方法沒有被調用。
是的,它現在正在工作.. 雅..我記得有些時候,我瞭解到..我們需要有這些元素來識別註釋.. – javanoob 2010-08-08 13:48:02