Jeka1978 / auto-comlete-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

in order that intelij will be able to autocomplete properties in application.properties/yaml, it needs file names spring-configuration-metadata.json
which looks like:
{
  "groups": [
    {
      "name": "db",
      "type": "com.epam.jeka.autocomletedemo.DbProps",
      "sourceType": "com.epam.jeka.autocomletedemo.DbProps"
    }
  ],
  "properties": [
    {
      "name": "db.data-source1password",
      "type": "java.lang.String",
      "sourceType": "com.epam.jeka.autocomletedemo.DbProps"
    },
    {
      "name": "db.data-source1username",
      "type": "java.lang.String",
      "sourceType": "com.epam.jeka.autocomletedemo.DbProps"
    },
    {
      "name": "db.data-source2password",
      "type": "java.lang.String",
      "sourceType": "com.epam.jeka.autocomletedemo.DbProps"
    },
    {
      "name": "db.data-source2username",
      "type": "java.lang.String",
      "sourceType": "com.epam.jeka.autocomletedemo.DbProps"
    }
  ],
  "hints": []
}

in order that this file will be autogenerated you need to add dependency of
    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

this dependency like lombok will generate this file in precompilation phase for all beans marked with @ConfigurationProperties
This classes shouldn't be marked with @Component, just @ConfigurationProperties
In order to register them, you can use @EnableConfigurationProperties(MyPropertyHolderBean.class) above your configuration
* don't forget that you need setters and getters for all properties, or just use @Data of lombok



About


Languages

Language:Java 100.0%