commit
801d74ad0b
|
@ -0,0 +1,26 @@
|
|||
package com.baeldung.annotation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
@Component
|
||||
public class MyBean {
|
||||
|
||||
private final TestBean testBean;
|
||||
|
||||
public MyBean(TestBean testBean) {
|
||||
this.testBean = testBean;
|
||||
System.out.println("Hello from constructor");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void postConstruct() {
|
||||
System.out.println("Hello from @PostConstruct method");
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void preDestroy() {
|
||||
System.out.println("Bean is being destroyed");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.baeldung.annotation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestBean {
|
||||
|
||||
}
|
Loading…
Reference in New Issue