From the course: Spring Framework in Depth
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
Profiles - Spring Framework Tutorial
From the course: Spring Framework in Depth
Profiles
- [Instructor] We talked about using environment variables for flexing by environment. Sometimes there is a desire to change behavior based on pre-configured profiles. A case for this that I have used are injecting mocking behavior in a QA environment. Let's take a look at this in action in Spring. The first thing I want you to do is open up your application.config. And on the TimeService, we are going to mark @Profile ("!dev"). And now, we are going to add another bean. And we're going to say at @Profile("dev"). And then we will do a public TimeService. And we'll return a new TimeService with this time it being false. Now, the way that I'm going to do this is I'm actually going to create some configuration specifically for this. So I'm going to start with my initial configuration. I'm going to get rid of the greeting changes that we made before. So we're going to start there. And I'm going to set a VM argument of -Dspring.profiles.active=prod. And I'm going to name this one Prod. Now…