Questions tagged [spring-profiles]

Spring Profiles provide a way to segregate parts of an application configuration and make it only available in certain environments.

Spring Profiles provide a way to segregate parts of an application configuration and make it only available in certain environments.

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html

349 questions
23
votes
2 answers

Spring: Selecting @Service based on profile

I have an interface define as below: public interface MyService { } And two classes implementing it: @Service @Profile("dev") public class DevImplementation implements MyService { } and @Service @Profile("prod") public class ProdImplementation…
shyam
  • 6,681
  • 7
  • 28
  • 45
22
votes
2 answers

Yml config files "Inheritance" with Spring boot

I couldn't find a straight answer online. Do Spring Boot's yml files "inherit" from each other? I mean if I have: application.yml which has server: port: 80 host: foo and application-profile1.yml which has only server: port: 90 So if I start…
tomer.z
  • 1,033
  • 1
  • 10
  • 25
15
votes
5 answers

Correctly using Spring environment profiles in order to manage PropertySourcesPlaceholderConfigurer and sets of properties files

I am working on a Spring application and I am realizing that I have an issue with the way I manage my properties. I use Spring environment profiles in order to load my properties and I've recently added more profiles which has made my properties…
balteo
  • 23,602
  • 63
  • 219
  • 412
14
votes
1 answer

@IfProfileValue not working with JUnit 5 SpringExtension

I use junit5 with spring-starter-test, in order to run spring test I need to use @ExtendWith instead of @RunWith. However @IfProfileValue work with @RunWith(SpringRunner.class) but not with @ExtendWith(SpringExtension.class), below is my…
Chi Dov
  • 1,447
  • 1
  • 11
  • 22
14
votes
1 answer

Spring MVC @Controller and profiles

I have a spring mvc controller and I want to enable it only in some profiles (for example development and test). I know I can use the profile attribute of the beans element in xml configuration to limit the scope of my beans, but I'm using…
Kojotak
  • 2,020
  • 2
  • 16
  • 29
13
votes
3 answers

Run gradle task with Spring Profiles (Integration tests)

Need to run tests via gradle with spring profiles. gradle clean build I've added task: task beforeTest() { doLast { System.setProperty("spring.profiles.active", "DEV") } } test.dependsOn beforeTest And my test definition…
yazabara
  • 1,253
  • 4
  • 21
  • 39
13
votes
2 answers

What happens in Spring if I use the @ActiveProfiles annotation on a configuration class instead use it on the class that defines my beans?

I am studying for the Spring Core certification and I have some doubts related to the use of profiles into JUnit tests. So I know that if I annote a class in the following way: @Profile("stub") @Repository public class StubAccountRepository…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
13
votes
1 answer

Not loading a Spring bean when a certain profile is set

Background: So, I've got several beans that interface external systems. For development, it's convenient to mock the external systems and replace the interfacing beans with some implementations that produce more or less static responses. So what…
ZeroOne
  • 3,041
  • 3
  • 31
  • 52
12
votes
3 answers

How to inject active spring profile into logback

I'm using a spring boot project. Environment: ch.qos.logback:logback-core:jar:1.1.5 ch.qos.logback:logback-classic:jar:1.1.5 org.springframework.boot:spring-boot-starter-logging:jar:1.3.3.RELEASE In my project I'm using properties with…
Leonel
  • 2,796
  • 5
  • 25
  • 36
11
votes
1 answer

What is diff between spring.profiles.active vs spring.config.activate.on-profile?

What is exact difference between spring.profiles.active and spring.config.activate.on-profile? "WARN","msg":"Property 'spring.profiles' imported from location 'class path resource [application.yaml]' is invalid and should be replaced with…
Prashant kamble
  • 259
  • 2
  • 4
  • 11
11
votes
4 answers

Springboot - multiple property files per profile

Looking for best approach in configuring multiple Profile specific property files in Springboot application. Below is an example: -resources    -- application.properties        -- dev              --…
Gary
  • 111
  • 1
  • 1
  • 3
10
votes
6 answers

Profile specific custom property files in Spring boot

Wanted to check if Spring boot offers help to use configuration file apart from application.properties file. Ex: my-custom.properties file that can be profile specific, ex: my-custom-dev.properties for dev profile my-custom-uat.properties for uat…
Guru
  • 2,739
  • 1
  • 25
  • 27
10
votes
5 answers

How to add an active spring profile from an environment variable?

Until now, I'm setting the following environment variable in my ~/.bash_profile : export SPRING_PROFILES_ACTIVE=local This set my active spring profile. But now, I want to add the local profile to other profiles defined in application.properties…
Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
10
votes
1 answer

Modify active profiles and refresh ApplicationContext runtime in a Spring Boot application

I have a Spring boot Web application. The application is configured via java classes using the @Configurable annotation. I have introduced two profiles: 'install', 'normal'. If the install profile is active, none of the Beans that require DB…
SaWo
  • 1,515
  • 2
  • 14
  • 32
10
votes
2 answers

Spring Boot ignores beans from Java config class using Spring Profile

When I run my application on Eclipse with a classical context loading, no worries, the beans defines on the config class corresponding with the Spring Profile chosen are correctly instanciated. public class BasketHandlerLoader { public static…
Didasko
  • 301
  • 1
  • 3
  • 10
1
2
3
23 24