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, 2020 in Java by kartik
• 37,490 points
1,351 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, 2020 by Niroj
• 82,580 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
• 58,990 points
412 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
228 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,350 points
120 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, 2020 in Java by Niroj
• 82,580 points
4,843 views
0 votes
2 answers
+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 1,864 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, 2020 in Java by Niroj
• 82,580 points
503 views
0 votes
2 answers

How to log SQL statements in Spring Boot?

HI.. try using this in your properties file: logging.level.org. ...READ MORE

answered Sep 24, 2020 in Java by SRI

edited Sep 24, 2020 by Sirajul 2,140 views