File tree 2 files changed +34
-0
lines changed
spring-core/src/main/java/com/baeldung/annotation
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .baeldung .annotation ;
2
+
3
+ import org .springframework .stereotype .Component ;
4
+ import javax .annotation .PostConstruct ;
5
+ import javax .annotation .PreDestroy ;
6
+
7
+ @ Component
8
+ public class MyBean {
9
+
10
+ private final TestBean testBean ;
11
+
12
+ public MyBean (TestBean testBean ) {
13
+ this .testBean = testBean ;
14
+ System .out .println ("Hello from constructor" );
15
+ }
16
+
17
+ @ PostConstruct
18
+ private void postConstruct () {
19
+ System .out .println ("Hello from @PostConstruct method" );
20
+ }
21
+
22
+ @ PreDestroy
23
+ public void preDestroy () {
24
+ System .out .println ("Bean is being destroyed" );
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .annotation ;
2
+
3
+ import org .springframework .stereotype .Component ;
4
+
5
+ @ Component
6
+ public class TestBean {
7
+
8
+ }
You can’t perform that action at this time.
0 commit comments