https://github.com/brobert83/nav-yml
Spring boot yml config and Intellij navigation
https://github.com/brobert83/nav-yml
intellij springboot yml-files
Last synced: 3 months ago
JSON representation
Spring boot yml config and Intellij navigation
- Host: GitHub
- URL: https://github.com/brobert83/nav-yml
- Owner: brobert83
- Created: 2018-10-14T14:59:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-24T19:36:42.000Z (over 6 years ago)
- Last Synced: 2025-01-26T02:54:18.498Z (5 months ago)
- Topics: intellij, springboot, yml-files
- Language: Java
- Size: 275 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This repo illustrates how to setup a Spring boot app using yml based properties
By using this setup navigation is possible from the application.yml file to where the properties are bound in code, and back (Crtl+B, Crtl+click, etc)
Notice this dependency in pom.xml
```org.springframework.boot
spring-boot-configuration-processor
true```
### How to enable annotation processing in Intellij
### Properties not bound are highlighted

### The magic
This is what is basically needed, then just inject that bean wherever
```
@Configuration
@ConfigurationProperties("my.living.rent")
class Address {private String city;
private String country;public String getCity() {
return city;
}public void setCity(String city) {
this.city = city;
}public String getCountry() {
return country;
}public void setCountry(String country) {
this.country = country;
}
}
```Also, @EnableConfigurationProperties
```
@SpringBootApplication
@EnableConfigurationProperties
public class NavYmlApplication {public static void main(String[] args) {
SpringApplication.run(NavYmlApplication.class, args);
}}
```
### This is how it should look in the class, by clicking those green leafs the ide will take you to the location in the yml where that prop is declared
#### Notes:
- it does not work in combination with Lombok (@Getter @Setter)
- the annotation processing must be enabled in Intellij
- I've noticed that sometimes the IDE needs some time to make the binding happen (refresh the maven config)