Skip to content

Commit 6b6b26b

Browse files
Code Assignment complete
1 parent e77338a commit 6b6b26b

File tree

8 files changed

+38
-4
lines changed

8 files changed

+38
-4
lines changed

src/main/java/guru/springframework/bootstrap/profilesysout/DevProfileSysOut.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package guru.springframework.bootstrap.profilesysout;
22

3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.beans.factory.annotation.Value;
35
import org.springframework.context.annotation.Profile;
46
import org.springframework.stereotype.Component;
57

@@ -10,10 +12,12 @@
1012
@Profile("dev")
1113
public class DevProfileSysOut {
1214

13-
public DevProfileSysOut() {
15+
@Autowired
16+
public DevProfileSysOut(@Value("${guru.springframework.profile.message}") String msg) {
1417
System.out.println("##################################");
1518
System.out.println("##################################");
1619
System.out.println("## DEV ##");
20+
System.out.println(msg);
1721
System.out.println("##################################");
1822
System.out.println("##################################");
1923
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

src/main/java/guru/springframework/bootstrap/profilesysout/ProdProfileSysOut.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package guru.springframework.bootstrap.profilesysout;
22

3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.beans.factory.annotation.Value;
35
import org.springframework.context.annotation.Profile;
46
import org.springframework.stereotype.Component;
57

@@ -9,10 +11,13 @@
911
@Component
1012
@Profile("prod")
1113
public class ProdProfileSysOut {
12-
public ProdProfileSysOut() {
14+
15+
@Autowired
16+
public ProdProfileSysOut(@Value("${guru.springframework.profile.message}") String msg) {
1317
System.out.println("##################################");
1418
System.out.println("##################################");
1519
System.out.println("## PROD ##");
20+
System.out.println(msg);
1621
System.out.println("##################################");
1722
System.out.println("##################################");
1823
}

src/main/java/guru/springframework/bootstrap/profilesysout/QAProfileSysOut.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package guru.springframework.bootstrap.profilesysout;
22

3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.beans.factory.annotation.Value;
35
import org.springframework.context.annotation.Profile;
46
import org.springframework.stereotype.Component;
57

@@ -10,10 +12,12 @@
1012
@Profile("qa")
1113
public class QAProfileSysOut {
1214

13-
public QAProfileSysOut() {
15+
@Autowired
16+
public QAProfileSysOut(@Value("${guru.springframework.profile.message}") String msg) {
1417
System.out.println("##################################");
1518
System.out.println("##################################");
1619
System.out.println("## QA ##");
20+
System.out.println(msg);
1721
System.out.println("##################################");
1822
System.out.println("##################################");
1923
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
guru.springframework.profile.message=This is my DEV profile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
guru.springframework.profile.message=This is my production profile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
guru.springframework.profile.message=This is my QA Profile

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ guru.jms.port=3330
55
guru.jms.user=Ron
66
guru.jms.password=Burgundy
77

8-
#spring.profiles.active=dev
8+
spring.profiles.active=dev

0 commit comments

Comments
 (0)