Spring Boot implement custom configuration automatically prompts IDE

file

One, background

Spring boot starter configuration items provided by the official, when we use the IDE configuration generally have automatically prompt, as shown in the following figure
file
and our own custom configuration did not, on the development of very unfriendly easily configured wrong, that this is how to achieve it?

 

Second, the principle of prompt

IDE is a configuration metadata information automatically by reading the tips, and the metadata in the directory META-INFin spring-configuration-metadata.jsonoradditional-spring-configuration-metadata.json

 

Third, to achieve automatic tips

In my own development starter in this custom configuration file, for example, if you manually create their own metadata, then the workload is relatively large, the use of IDEAthe words are automatically generated function
file

 

3.1. Introducing dependent spring-boot-configuration-processor

In the zlt-swagger2-spring-boot-starterAdd the following jar package project

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <optional>true</optional>
</dependency>

 

3.2. Modify the configuration IDEA

Search Annotation Processorand setEnable annotation processing
file

 

3.3. Rebuild the project

The project will be generated automatically recompile spring-configuration-metadata.jsonfiles
file

 

Fourth, the test

swagger configure a custom has been automatically suggests
file

 
References
https://docs.spring.io/spring-boot/docs/current/reference/html/configuration-metadata.html

 
Recommended Reading

Guess you like

Origin www.cnblogs.com/zlt2000/p/11386751.html