Questions tagged [spring-config]

Refers to the org.springframework.context.annotation package of the Spring Framework that moves bean definition and Spring configuration out of XML file and into Java classes via annotations.

Questions referring to @Configuration and @Bean will be the primary source of questions for this tag.

Useful Links

178 questions
4
votes
2 answers

Refresh Spring Boot Auto-Configured Properties

Can I dynamically refresh properties that are used by Spring Boot's auto configuration setup? For example, I have the following properties set (via cloud config) to auto configure a…
pChip
  • 405
  • 1
  • 6
  • 15
4
votes
0 answers

Spring Boot - JavaMailSender not created when using a yml config file in a common (library) project

I have a common Spring Boot project used by other Spring Boot projects. So, I have a multi-module setup. The common project uses Java Mail and I want configure it in the common project. Per Spring Boot doc, If spring.mail.host and the relevant…
James
  • 2,876
  • 18
  • 72
  • 116
4
votes
4 answers

Spring Framework 5.0.0.Final parent context not getting loaded

I was trying with latest spring 5.0.0.Final with my EAR project which has a parent context defined in web.xml using context-param with param names locatorFactorySelector and parentContextKey but spring could not able to load the parent context.…
Sreekanth
  • 539
  • 1
  • 7
  • 24
3
votes
0 answers

What's the size limitiation of Spring Cloud Config?

We are using Spring Boot, Spring Cloud Configurations and generate the application.yaml from an external source. This yaml file has about 53k lines of configuration and a file size of 2.7mb. Unfortunately, the spring application fails starting when…
3
votes
2 answers

Spring Boot initialize new instance for nested configuration binding when there are no corresponding nested key/value pairs in application.properties

I have a configuration class like below. All of fields in the inner class OptionalServiceConfigs has a default value as annotated using @Value as shown in below. Sometimes in my application.properties file, it does not have a single service prefixed…
isuru89
  • 742
  • 11
  • 19
3
votes
1 answer

How to Inject custom method argument in Spring WebFlux using HandlerMethodArgumentResolver?

I want to create an custom method argument Resolver using Spring WebFlux. I am following link but its seem to be not working. I am able to create the custom argument resolver using WebMvc. import…
S Atah Ahmed Khan
  • 1,313
  • 3
  • 14
  • 22
3
votes
1 answer

Spring Boot 2.0.5 can not bind list of properties from spring-cloud-config server

I've run into a next situation: I've migrated my application from Spring Boot 1.5.x to Spring Boot 2.0.5. I have the next class: @ConfigurationProperties(prefix = "some.property") public class Myclass { @Getter @Setter private List
Alfred Moon
  • 987
  • 1
  • 10
  • 21
3
votes
1 answer

Refresh springboot configuration dynamically

Is there any way to refresh springboot configuration as soon as we change .properties file? I came across spring-cloud-config and many articles/blogs suggested to use this for a distributed environment. I have many deployments of my springboot…
MLS
  • 617
  • 1
  • 7
  • 14
3
votes
4 answers

Spring Boot 2 use dev profile if prod profile is not exist

I have Spring Boot Application and i have 3 property files: applications.properties, applications-dev.properties, applicaton-prod.properties. In applications.properties i specify that spring.profiles.active=prod. But I want to allow startup of…
Abzelhan
  • 510
  • 1
  • 7
  • 26
3
votes
0 answers

using @Value to inject a map from yml file to a config property in spring boot

I am trying to inject a map like this from yml redisDbIndex: key1: 1 key2: 2 key3: 3 into a Map map = new HashMap<>(); And in my configuration class ( I don't want to use @ConfigurationProperties(prefix="...") annotation as…
Mukul Anand
  • 606
  • 6
  • 24
3
votes
1 answer

Spring Boot: Profiles ignored in PropertySourcesPlaceholderConfigurer loaded file

I have a library that is a Spring Boot project. The library has a library.yml file that contains dev and prod props for its configuration: library.yml --- spring: profiles: active: dev --- spring: profiles: dev env: dev --- spring: …
James
  • 2,876
  • 18
  • 72
  • 116
2
votes
0 answers

Thread-safeness and resource leaking in a @Configuration class

I had to create a singleton bean manually in a @Configuration class in order to share it without exposing it into the context (which triggers conditionals/autoconfigures). I have been pointed to the awareness of certain risks to manage it by…
Whimusical
  • 6,401
  • 11
  • 62
  • 105
2
votes
1 answer

Passing spring.config.location in bootRun task

I wanted to change the spring.config.additional-location for my gradle springboot app to run local. There's a properties file in my C:/demo_class_path and it's outside the jar. I was trying to access those properties in code. the command java -jar…
Hannah Han
  • 79
  • 1
  • 8
2
votes
1 answer

Return anything other than null

My code used to work until I added the sslEnabled configuration. Since I put "false" as the default value for sslEnabled, it will return null. And that null causes me the following: Caused by:…
user10867569
  • 157
  • 2
  • 6
2
votes
1 answer

Spring - @Autowired bean from @Configuration is null

I define a bean in a configuration class. I would like to autowire this bean in a component. However, the property stays null. E.g.: Appconfiguration.java @Configuration public class AppConfiguration { @Bean public SomeType someObject() { …
nagy.zsolt.hun
  • 6,292
  • 12
  • 56
  • 95
1
2
3
11 12