spring-profiles

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

拟墨画扇 提交于 2020-01-04 02:32:07
问题 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 config annotated with the profile they are active for. I run my cucumber tests defining which profile is the active one but this forces me to manually change the string every time I want to test a different profile, making it impossible to run

How do you properly set different Spring profiles in bootstrap file (for Spring Boot to target different Cloud Config Servers)?

本秂侑毒 提交于 2019-12-30 01:55:46
问题 We have different config servers per environment. Each spring boot application should target its corresponding config server. I have tried to achieve this by setting profiles in the bootstrap.properties file, e.g.: spring.application.name=app-name spring.cloud.config.uri=http://default-config-server.com --- spring.profiles=dev spring.cloud.config.uri=http://dev-config-server.com --- spring.profiles=stage spring.cloud.config.uri=http://stage-config-server.com --- spring.profiles=prod spring

How to set Spring profile from system variable?

筅森魡賤 提交于 2019-12-29 03:25:05
问题 I have a Spring project which uses another project. Each project has its own spring profile initialize from java code using applicationContext.xml and *.properties for each profile. I inject the profile from args[] . The problem is that second project uses the default configuration for the env from the applicationContext.xml I can not inject the env from args[] to the second project and I tried looking for an article which will explain how Spring profile works. Is there a hierarchy on which

spring boot always using the same profile

*爱你&永不变心* 提交于 2019-12-24 02:28:06
问题 I am using spring boot 1.5.2, and using profiles but I found a very strange thing. my spring boot resources folder like this: configs in application.yml spring: profiles: active: @profileActive@ application-dev.yml spring: profiles: dev datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/db1 username: root password: server: port: 8080 application-test.yml spring: profiles: test datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost

Loading environment specific properties file in spring

落花浮王杯 提交于 2019-12-23 23:50:26
问题 I am working on a spring-boot application, I need your assistance on below scenario. I have properties files for each environment something like application-dev.properties, application-prod.properties etc. Is there way that my application can load environment specific properties file by using spring @Profile annotation. Please help. 回答1: You don't need to use @Profiles annotation at all. Just use @ConfigurationProperties(locations = "classpath:myapp-${environment.type}.properties") and define

refresh property placeholder mechanism at Spring

 ̄綄美尐妖づ 提交于 2019-12-23 01:54:39
问题 I have a Spring context xml file and a specific bean into it that created by a PropertyPlaceholderConfigurer mechanism. My problem is: When the application is working related properties file changes and I don't want restart application. I want reload related bean without restart application. What is best solution for my goal? 回答1: you can have a look at ReloadablePropertiesAnnotation on github https://github.com/jamesemorgan/ReloadablePropertiesAnnotation this should just work by annotating

Including bean definition when a profile is NOT active

馋奶兔 提交于 2019-12-22 01:46:07
问题 In my application I use several profiles to make certain beans eligible for autowiring. What I'm missing is the possibility to make a bean eligible for autowiring when a certain profile is NOT active. The best way of doing it that I thought about is like this: Let's suppose we have a list of all possible profiles, e.g. {A, B, C, D}. Profiles active for particular execution are {A, C}. What I do is I create artificial profiles for all possible profiles which are not active. In the example case

Loading util:properties with Spring Profile causes multiple occurrences of ID

孤街浪徒 提交于 2019-12-19 04:55:43
问题 I am using Spring(3.1) profiles to load property files vis util:properties: <beans profile="local"> <util:properties id="myProps" location="classpath:local.properties" /> </beans> <beans profile="dev"> <util:properties id="myProps" location="classpath:dev.properties" /> </beans> And I invoke the profile via a runtime parameter(running on TC Server): -Dspring.profiles.active=local But I get the error There are multiple occurrences of ID value 'myProps' This was running previously with other

SpringBoot: Unable to find a single main class from the following candidates

这一生的挚爱 提交于 2019-12-18 10:51:32
问题 I've generated a Spring Boot web application using Spring Initializer, embedded Tomcat, Thymeleaf template engine.Technologies used: Spring Boot 1.4.2.RELEASE, Spring 4.3.4.RELEASE, Thymeleaf 2.1.5.RELEASE, Tomcat Embed 8.5.6, Maven 3, Java 8 I have an SpringBoot app. with these 2 classes: @Profile("!war") @SpringBootApplication @Import({SecurityConfig.class ,PersistenceConfig.class, ServiceConfig.class}) public class BookApplication { public static void main(String[] args) {

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

帅比萌擦擦* 提交于 2019-12-18 05:55:53
问题 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 connection is loaded. I want to create a controller where the user can set up the db connection parameters and When it's done I want to switch the active profile from 'install' to 'normal' and refresh the application context, so the Spring can init every