Questions tagged [spring-properties]

166 questions
5
votes
2 answers

How to access application-{profile}.properties file based on active profile

I have a requirement of accessing application.properties file outside the project location. I am able to achieve the same using following : @Component @PropertySources({ @PropertySource(value =…
5
votes
5 answers

Spring Boot command line property not overriding property defined in application.properties

I have created a Spring Boot app which uses a legacy library. This legacy library defines a number of Spring Beans in XML. One of which take in a property value as a constructor argument:
5
votes
1 answer

Spring YAML profile configuration

I'm not sure if I well understand how Spring profiles works with yaml and properties files. I was trying to misc those two types of configuration (the two file do not share any configuration) but i'm having problems when reading profiles from yaml…
4
votes
2 answers

Changing delimiter in @ConfigurationProperties for reading a List property

I have a list of values in one property in application.properties file: my-property=abc,def,ghi And I load it in my @ConfigurationProperties class: @Configuration @ConfigurationProperties public class MyProperties { private List
mkczyk
  • 2,460
  • 2
  • 25
  • 40
4
votes
0 answers

How should I pull my passwords from AWS Secret Manager into spring?

I'd like to retrieve my database password from the AWS Secret Manager based off of a key name set in my properties files. It doesn't seem like I can read properties from the application.yml file like I had hoped, however. In the code below,…
Sammaron
  • 196
  • 1
  • 3
  • 14
4
votes
2 answers

Spring include relative path in properties

I'm trying to make it so that in config/app.properties, I can have: myfile.location=./myfile where . is relative to said properties file. Is this possible ? I tried: resourceLoader.getResource(appConfig.getMyFileLocation()); where resourceLoader…
Vinz243
  • 9,654
  • 10
  • 42
  • 86
4
votes
0 answers

Spring @Value using wildcard

Can I use wildcard in Spring @Value,as following ? @Value("${key.*}) private String [] keys; I want that above match all keys start with "key." word
emanuel07
  • 738
  • 12
  • 27
3
votes
0 answers

Spring Polymorphic Properties: CustomBindHandler works but not for Lists

I have a bunch of entities, I would like to load from the application.yaml file. The structure seems rather complex but it is as it is and that includes polymorphism with some classes: This is the base structor for the properties I want to…
user3235738
  • 335
  • 4
  • 22
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
3 answers

Spring boot property value conversion from String to Duration works in application, fails in unit test

According to the spring docs, string property values such as 10s will be properly converted into a java.time.Duration. Indeed this works for me with the main application properties. But it fails in a unit test. unit…
marathon
  • 7,881
  • 17
  • 74
  • 137
3
votes
2 answers

Is there a way to validate @Value in spring boot?

I'm using @Value to inject parameters from my properties file to variable in my application. Because I'm not the only user in the application and I want to make the injection safety I need to validate the parameter before the injection.…
Lupidon
  • 599
  • 2
  • 17
3
votes
1 answer

Use Spring properties loading without initializing the Spring context

I love the Spring properties loading mechanism. The fact that you can define several profiles and override or extend properties with other profiles, that you can use different file types (.properties, XML, JSON, ...) to store your properties, that…
Schorsch
  • 203
  • 1
  • 2
  • 9
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

How to load a bean only if a property is false or not defined?

I've a bean that should be loaded only if a property is false or not defined. If I annotate it with: @ConditionalOnProperty(prefix = "myFeature1", name = "enable", havingValue = "false") the property myFeature1.enable has to be explicitly set to…
Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
3
votes
2 answers

How to convert Type with generics into a Class in java?

I have a method objet. I would like to extract return Type with generics and convert it to a Class in order to pass such information into Spring PropertyResolver. Type type = myMethod.getGenericReturnType(); Class returnType = /* ???…
pixel
  • 24,905
  • 36
  • 149
  • 251
1
2
3
11 12