Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize IDE automatic prompt through self-defined configuration in Spring Boot

Shulou Source: shulou.com Published: 2022-06-02 05:58:37 11月14日 Update

Today, I will talk to you about how to realize IDE automatic prompt through custom configuration in Spring Boot. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

I. background

The official spring boot starter configuration items are usually prompted automatically when we configure them with IDE, as shown in the following figure.

However, we do not have our own custom configuration, and it is very unfriendly to developers and easy to type the wrong configuration, so how is this achieved?

Second, prompt principle

IDE is prompted automatically by reading the metadata of the configuration information, while the metadata is in the spring-configuration-metadata.json or additional-spring-configuration-metadata.json in the directory META-INF

Third, realize automatic prompt

Take the custom configuration file in starter developed by myself as an example. If you create these metadata manually, you will have a lot of work, and if you use IDEA, you can generate them automatically.

3.1. Introduce dependency spring-boot-configuration-processor

Add the following jar package to the zlt-swagger2-spring-boot-starter project

Org.springframework.boot spring-boot-configuration-processor true3.2. Modify IDEA configuration

Search for Annotation Processor and set Enable annotation processing

3.3. Recompile the project

The spring-configuration-metadata.json file is automatically generated when the project is recompiled

IV. Testing

Custom swagger configuration can be prompted automatically.

After reading the above, do you have any further understanding of how to realize IDE automatic prompt through custom configuration in Spring Boot? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Configuration prompts content data files automatic generation projects development generation compilation information functions principles official workload engineering manual time more directories Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL Redmi Shulou Technology MariaDB