spring-profiles

How to load only profile specific property file and ignore default application.properties?

可紊 提交于 2021-02-11 15:00:55
问题 I have a normal spring boot application, and two property files in resources folder: application.properties com.example.prop1=value1 com.example.enableMock=true application-dev.properties com.example.prop1=value11 I have some logic based on whether com.example.enableMock is present or missing. Problem is spring loads both files even if spring.profiles.active=dev and the application is getting the com.example.enableMock property. How do I just load profile specific property file? 回答1: By

spring maven profile - set properties file based on compilation profile

随声附和 提交于 2021-02-10 12:14:02
问题 I would create some compilation profiles like these: profile name: dev profile name: test profile name: production In src/main/resources I have 3 folders: dev/file.properties test/file.properties production/file.properties Each file contains different values for this properties: - my.prop.one - my.prop.two - my.prop.three After that I would set in Spring classes something like these: @Configuration @PropertySource("file:${profile_name}/file.properties") public class MyConfig{ } How can I do?

spring maven profile - set properties file based on compilation profile

て烟熏妆下的殇ゞ 提交于 2021-02-10 12:12:55
问题 I would create some compilation profiles like these: profile name: dev profile name: test profile name: production In src/main/resources I have 3 folders: dev/file.properties test/file.properties production/file.properties Each file contains different values for this properties: - my.prop.one - my.prop.two - my.prop.three After that I would set in Spring classes something like these: @Configuration @PropertySource("file:${profile_name}/file.properties") public class MyConfig{ } How can I do?

@IfProfileValue not working with JUnit 5 SpringExtension

大城市里の小女人 提交于 2021-02-08 13:19:38
问题 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 code: @SpringBootTest @ExtendWith({SpringExtension.class}) class MyApplicationTests{ @Test @DisplayName("Application Context should be loaded") @IfProfileValue(name = "test-groups" , value="unit-test") void contextLoads() { } } so the contextLoads should be

@IfProfileValue not working with JUnit 5 SpringExtension

Deadly 提交于 2021-02-08 13:19:31
问题 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 code: @SpringBootTest @ExtendWith({SpringExtension.class}) class MyApplicationTests{ @Test @DisplayName("Application Context should be loaded") @IfProfileValue(name = "test-groups" , value="unit-test") void contextLoads() { } } so the contextLoads should be

Spring “spring.profiles.include” overrides

那年仲夏 提交于 2020-11-30 04:38:07
问题 My intention is to have two profiles in a spring boot application - development and production one. Development profile is meant just to override some variables of production profile (like in-memory database instead of database in the cloud). As I expect some changes to be done to production profile in the future, duplicating variables in development profile doesn't seem to be a solution. So, in Spring Reference I read that spring.profiles.include is supposed to only add properties from

Spring “spring.profiles.include” overrides

百般思念 提交于 2020-11-30 04:37:07
问题 My intention is to have two profiles in a spring boot application - development and production one. Development profile is meant just to override some variables of production profile (like in-memory database instead of database in the cloud). As I expect some changes to be done to production profile in the future, duplicating variables in development profile doesn't seem to be a solution. So, in Spring Reference I read that spring.profiles.include is supposed to only add properties from

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

落爺英雄遲暮 提交于 2020-04-05 05:13:23
问题 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: <filter> <filter-name>OpenEntityManagerInViewFilter</filter-name> <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>OpenEntityManagerInViewFilter</filter-name> <url-pattern>/*</url-pattern> <

spring profile groups

百般思念 提交于 2020-01-04 15:58:27
问题 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 profiles -Dspring.profiles.active=production,cached-local,db-connection-pooled... but I would prefer initializing it as -Dspring.profiles.active=production,super-fast #the above activates method level caches, db connection pooling etc #super-fast

spring profile groups

和自甴很熟 提交于 2020-01-04 15:58:06
问题 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 profiles -Dspring.profiles.active=production,cached-local,db-connection-pooled... but I would prefer initializing it as -Dspring.profiles.active=production,super-fast #the above activates method level caches, db connection pooling etc #super-fast