Problem
When creating a Spring Context (using the DSL), application properties is not read unless explicitly stated. The reason it was prievously believed to be working is that Spring still starts H2 automatically, but with a default name and settings (which was not checked earlier). I forgot that application.properties autoloading was a Spring Boot feature, so a seperate Spring Boot context (or modifying the existing one) should probably be added.
How to reproduce
- Create a Spring Boot application.
- Do any operations which reads from application properties (either yaml file or .properties), and do NOT specify property sources.
Expected behaviour
Application properties are read and can be referenced either by using Environment, doing operations on database or something else. This reflects what is expected from Spring in JUnit tests, and this project aims to give you all the same features.
Possible solution
There are several possible solutions.
- Do SpringApplication.run to get ApplicationContext. The downside here is that it may interfere with CommandLineRunners (which are common in many batch systems).
- Do manual handling of property sources. Check if files exists and add them manually to the context.
- Some unknown internal Spring settings that can be done to get it to read the properties.