Skip to content

Commit e77338a

Browse files
Profiles at Runtime
1 parent 3d15e5d commit e77338a

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/main/java/guru/springframework/bootstrap/profilesysout/DefaultProfileSysOut.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("default")
1113
public class DefaultProfileSysOut {
1214

13-
public DefaultProfileSysOut() {
15+
@Autowired
16+
public DefaultProfileSysOut(@Value("${guru.springframework.profile.message}") String msg) {
1417
System.out.println("##################################");
1518
System.out.println("##################################");
1619
System.out.println("## DEFAULT ##");
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 a default 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)