File tree Expand file tree Collapse file tree 8 files changed +38
-4
lines changed
java/guru/springframework/bootstrap/profilesysout Expand file tree Collapse file tree 8 files changed +38
-4
lines changed Original file line number Diff line number Diff line change 1
1
package guru .springframework .bootstrap .profilesysout ;
2
2
3
+ import org .springframework .beans .factory .annotation .Autowired ;
4
+ import org .springframework .beans .factory .annotation .Value ;
3
5
import org .springframework .context .annotation .Profile ;
4
6
import org .springframework .stereotype .Component ;
5
7
10
12
@ Profile ("dev" )
11
13
public class DevProfileSysOut {
12
14
13
- public DevProfileSysOut () {
15
+ @ Autowired
16
+ public DevProfileSysOut (@ Value ("${guru.springframework.profile.message}" ) String msg ) {
14
17
System .out .println ("##################################" );
15
18
System .out .println ("##################################" );
16
19
System .out .println ("## DEV ##" );
20
+ System .out .println (msg );
17
21
System .out .println ("##################################" );
18
22
System .out .println ("##################################" );
19
23
}
Original file line number Diff line number Diff line change
1
+ package guru .springframework .bootstrap .profilesysout ;
2
+
3
+ import org .springframework .beans .factory .annotation .Autowired ;
4
+ import org .springframework .beans .factory .annotation .Value ;
5
+ import org .springframework .stereotype .Component ;
6
+
7
+ /**
8
+ * Created by jt on 5/21/16.
9
+ */
10
+ @ Component
11
+ public class NonProfileBean {
12
+
13
+ @ Autowired
14
+ public NonProfileBean (@ Value ("${guru.springframework.profile.message}" ) String msg ) {
15
+ System .out .println ("**********" + msg + "************" );
16
+
17
+ }
18
+ }
Original file line number Diff line number Diff line change 1
1
package guru .springframework .bootstrap .profilesysout ;
2
2
3
+ import org .springframework .beans .factory .annotation .Autowired ;
4
+ import org .springframework .beans .factory .annotation .Value ;
3
5
import org .springframework .context .annotation .Profile ;
4
6
import org .springframework .stereotype .Component ;
5
7
9
11
@ Component
10
12
@ Profile ("prod" )
11
13
public class ProdProfileSysOut {
12
- public ProdProfileSysOut () {
14
+
15
+ @ Autowired
16
+ public ProdProfileSysOut (@ Value ("${guru.springframework.profile.message}" ) String msg ) {
13
17
System .out .println ("##################################" );
14
18
System .out .println ("##################################" );
15
19
System .out .println ("## PROD ##" );
20
+ System .out .println (msg );
16
21
System .out .println ("##################################" );
17
22
System .out .println ("##################################" );
18
23
}
Original file line number Diff line number Diff line change 1
1
package guru .springframework .bootstrap .profilesysout ;
2
2
3
+ import org .springframework .beans .factory .annotation .Autowired ;
4
+ import org .springframework .beans .factory .annotation .Value ;
3
5
import org .springframework .context .annotation .Profile ;
4
6
import org .springframework .stereotype .Component ;
5
7
10
12
@ Profile ("qa" )
11
13
public class QAProfileSysOut {
12
14
13
- public QAProfileSysOut () {
15
+ @ Autowired
16
+ public QAProfileSysOut (@ Value ("${guru.springframework.profile.message}" ) String msg ) {
14
17
System .out .println ("##################################" );
15
18
System .out .println ("##################################" );
16
19
System .out .println ("## QA ##" );
20
+ System .out .println (msg );
17
21
System .out .println ("##################################" );
18
22
System .out .println ("##################################" );
19
23
}
Original file line number Diff line number Diff line change
1
+ guru.springframework.profile.message =This is my DEV profile
Original file line number Diff line number Diff line change
1
+ guru.springframework.profile.message =This is my production profile
Original file line number Diff line number Diff line change
1
+ guru.springframework.profile.message =This is my QA Profile
Original file line number Diff line number Diff line change @@ -5,4 +5,4 @@ guru.jms.port=3330
5
5
guru.jms.user =Ron
6
6
guru.jms.password =Burgundy
7
7
8
- # spring.profiles.active=dev
8
+ spring.profiles.active =dev
You can’t perform that action at this time.
0 commit comments