Development notes: springboot custom configuration
Preface: This article is compiled by the editor of Programming Notes#, mainly introduces the knowledge related to springboot custom configuration, and hopes to have certain reference value for you. springboot custom configuration (to solve automatic prompt Chinese garbled characters) 1. Description In the development of springboot, we sometimes need to write some parameters into the yml configuration for easy modification after deployment. At this time, we can use the custom configuration function provided by springboot 2. Introduce dependencies dependency> groupId>org.springframework.boot</groupId> artifactId>spring-boot-configuration-processor</ artifactId> optional>true</optional></dependency> 3. Write a custom configuration class Example: import lombok.Data;import org.springframework.boot.context. properties.ConfigurationProperties;/** * Some configurations of the client */@ConfigurationProperties(prefix = “client.config”)@Datapublic class ClientConfig { /** * base url */ private String baseUrl;} 4. Use IDEA to compile and generate spring -configuration-metadata.json file The spring-configuration-metadata.json file generated after compilation is in the following path: The role of the spring-configuration-metadata.json file is Let us provide automatic prompts when entering configurations in yml or properties files, as follows: Also: If the above automatic prompt appears Chinese garbled characters, change spring-configuration-metadata.json The encoding format of the file is changed from utf-8 to gbk, and the Chinese prompt will be displayed normally. The specific operation is as follows: 1) Click the encoding in…