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
4
votes
1 answer

Can't autowire Spring Environment

I need to determine the current active Spring profile during runtime. In other answers I found that the following should be sufficient: @Aspect @Component public class MeasureExecTime { @Autowired private Environment environment; …
Eugene S
  • 6,709
  • 8
  • 57
  • 91
4
votes
2 answers

Spring Boot throws ClassNotFoundException with maven dependency for another project

I have Spring Boot project with simple EnvironmentPostProcessor implementation: package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; import…
catch23
  • 17,519
  • 42
  • 144
  • 217
4
votes
3 answers

Is Spring's @Profile on methods a good practice

I have a Spring Boot Web application exposing rest services. I'm asking myself how to correctly manage profiles on Filters. Actually, my app has 2 profiles: dev and prod (you guess what it stands for...) In prod mode, i have more filters to activate…
Lucas.de
  • 555
  • 8
  • 17
4
votes
1 answer

Spring @Autowire field based on @Profile

I need to autowire fields based on the spring.profiles.active property. The service is only created based on the profile but the since the service is autowired in other classes I am unable to use the @Profile annotations. Is there a way to autowire…
unnik
  • 1,123
  • 5
  • 18
  • 37
4
votes
1 answer

Is it possible to configure cucumber to run the same test with different spring profiles?

I have an application where I'm running a trial with different technologies. I have a set of interfaces implemented with each technology and I use spring profiles to decide which technology to run. Each of the technologies has its own Spring java…
Juan Vega
  • 1,030
  • 1
  • 16
  • 32
4
votes
1 answer

Enabling/disabling a web.xml filter using a Spring profile

I have a Spring application that can use two different persistence API: Spring Data JPA Spring Data Neo4j When using Spring Data JPA, I need to declare the "OpenEntityManagerInViewFilter" in "web.xml" to do lazy loading:
Grégoire C
  • 1,361
  • 1
  • 13
  • 32
4
votes
1 answer

Using Spring profiles with fallback

I've set the environment variable SPRING_PROFILES_ACTIVE on my local linux machine: $ echo $SPRING_PROFILES_ACTIVE development,develop,devel,dev In my servlet initializer I'm setting a default profile as I didn't set any variables on my productive…
dtrunk
  • 4,685
  • 17
  • 65
  • 109
4
votes
3 answers

spring profile not activated on STS tc Server

I have a project with Spring profile In my web.xml, i have spring.profiles.default dev to set the default spring profile. I build the maven project with…
SooCheng Koh
  • 2,271
  • 3
  • 21
  • 34
4
votes
2 answers

spring profile groups

I have an application, for which I can specify the profiles I want to run it on. but I also want to group these profiles into things like credentails, application performance, memory-print, application behaviour etc. Ex. I can run the following…
user918953
  • 173
  • 1
  • 2
  • 9
3
votes
2 answers

Spring boot override prod properties from additional location file

In my application I have these properties files: application.properties application-prod.properties Inside I have the same property spring.datasource.password=my-dev-password #for the default…
flywell
  • 384
  • 3
  • 20
3
votes
4 answers

spring.profiles.active is not working in springboot application

I have created Profiles in Java class like this, @Profile(value = "cache") public class MapCache { .... } These profiles are not getting activated when spring.profiles.active used, but if i use spring.profiles.include profiles are working fine. I…
Sunil Rk
  • 999
  • 6
  • 12
  • 35
3
votes
1 answer

Profiles In dagger

I am new to dagger and I am searching for how can we implement functionality like spring profiles in dagger-2.x. I want different beans for my devo and prod environments, but I am using dagger framework with Java. @Provides @Singleton public void…
blackbird
  • 53
  • 6
3
votes
2 answers

spring.application.name property in application.yaml is fetched as null if profile is active

I have an application.yaml file which specifies the service's name: spring: application: name: "my-microservice" Now, when I try to fetch it using @Value("spring.application.name") inside my code, I'm able to do that successfully. But I'm…
3
votes
0 answers

When spring looks to test/resources?

Working on unit tests in Spring boot application and came across an issue: I put application.properties data.sql files under src/main/resources and application-test.properties data-test.sql files under src/test/resources But realized when…
J.J. Beam
  • 2,612
  • 2
  • 26
  • 55
3
votes
1 answer

How to use Spring profiles to mock different services that implement the same interface

I have the following scenario: I have a Springboot microservice that can gather a list of products from different providers (external SOAP web services). We currently get the information from 2 providers, for instance Amazon and EBay. But in the…
Marcelo Tataje
  • 3,849
  • 1
  • 26
  • 51