How to determine programmatically the current active profile using Spring boot ?

0 votes
Hii team,

Is there a way programmatically to get the current active profile within my bean?
May 21 in Java by kartik
• 11,890 points
32 views

1 answer to this question.

0 votes

Hello,

It doesn't matter is your app Boot or just raw Spring. There is just enough to inject org.springframework.core.env.Environment to your bean.

@Autowired
private Environment environment;
....

this.environment.getActiveProfiles();

Hope this is helpfull!!

answered May 21 by Niroj
• 23,950 points

Related Questions In Java

0 votes
2 answers

How do I get the current date and time using Java?

If you require a time stamp in ...READ MORE

answered Aug 23, 2019 in Java by Sirajul
• 53,110 points
225 views
0 votes
2 answers

How to read the files using Java?

You can use collections. try (Stream<Path> filePathStream=Files.walk(Paths.get("/home/you/Desktop"))) { ...READ MORE

answered Jul 10, 2018 in Java by Sushmita
• 6,890 points
114 views
0 votes
1 answer

How to get the IP address of the machine using Java?

One approach is to use NetworkInterface.getNetworkInterfaces() to get all ...READ MORE

answered Jun 25, 2018 in Java by sharth
• 3,370 points
59 views
0 votes
1 answer

How to set base url for rest in spring boot?

Hello @kartik, Set it up in your application.yml ...READ MORE

answered May 22 in Java by Niroj
• 23,950 points
63 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 963 views
0 votes
0 answers
0 votes
1 answer

How to configure port for a Spring Boot application?

Hello @kartik, You can set port in java ...READ MORE

answered May 22 in Java by Niroj
• 23,950 points
39 views
0 votes
1 answer

How to log SQL statements in Spring Boot?

Hello @kartik, If you hava a logback-spring.xml or ...READ MORE

answered May 22 in Java by Niroj
• 23,950 points
43 views