Unlock SpringBoot 3.3.0: Adding Descriptions to Record Components via Configuration Metadata
This article explains SpringBoot 3.3.0's new support for adding description metadata to record components, covering configuration metadata basics, how to generate the metadata file, and step‑by‑step examples using both classic Java classes and Java records.
Environment
SpringBoot 3.3.0 was released on May 23, 2024. The release adds a single new feature—support for describing record components in configuration metadata—along with numerous bug fixes.
1. Update Content
The new feature adds support for the record component description in the generation of configuration metadata.
1.1 Configuration Metadata
SpringBoot JARs contain a META-INF/spring-configuration-metadata.json file that lists all supported configuration properties, groups, and hints. IDEs use this file to provide context help and code completion for application.properties or application.yml .
Typical JSON structure:
<code>{
"groups": [
{
"name": "server",
"type": "xxx.ServerProperties",
"sourceType": "xxx.ServerProperties"
},
...
],
"properties": [
{
"name": "server.port",
"type": "java.lang.Integer",
"sourceType": "xxx.ServerProperties"
},
...
],
"hints": [
{
"name": "spring.jpa.hibernate.ddl-auto",
"values": [
{"value": "none", "description": "Disable DDL handling."},
...
]
}
]
}
</code>The file enables IDE hints, as shown in the screenshots.
2. Practical Example
2.1 Environment Preparation
Add the configuration processor dependency so SpringBoot can generate the metadata file automatically:
<code><dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</code>2.2 Custom Configuration Properties (Java Class)
Create a POJO annotated with @Component and @ConfigurationProperties :
<code>@Component
@ConfigurationProperties(prefix = "pack.app1")
public class CommonProperties {
private String version;
private String title;
private Integer numbers;
// getters, setters
}
</code>Corresponding YAML configuration:
<code>pack:
app1:
title: xxx项目
version: 1.0.0
numbers: 1
</code>After building, spring-configuration-metadata.json is generated. Initially, description fields are missing for some JPA properties.
Adding Javadoc comments to each field adds description information to the metadata:
<code>/**
* Application version
*/
private String version;
/**
* Project title
*/
private String title;
/**
* Number of releases
*/
private Integer numbers;
</code>Rebuilding shows the descriptions appear in IDE hints.
2.3 Using Record Component
Java records can also be used as configuration properties:
<code>@Component
@ConfigurationProperties(prefix = "pack.app")
public record AppProperties(
String version,
String title,
Integer numbers
) {}
</code>Configuration file:
<code>pack:
app:
title: xxx项目
version: 1.0.0
numbers: 1
</code>Generated metadata lacks description because record fields do not inherit Javadoc from the record components.
2.4 SpringBoot 3.3.0 New Feature for Records
From version 3.3.0, you can provide description for each record component using Javadoc @param tags at the class level:
<code>/&#**
* @param version 1.1.3
* @param title XXXOOO项目标题
* @param numbers 第3次发版
*&#/
@Component
@ConfigurationProperties(prefix = "pack.app")
public record AppProperties(
String version,
String title,
Integer numbers
) {}
</code>After rebuilding, the generated spring-configuration-metadata.json includes the description information for the record components.
Conclusion
The new SpringBoot 3.3.0 feature enables developers to add descriptive metadata to record‑based configuration properties, improving IDE assistance and documentation quality.
Spring Full-Stack Practical Cases
Full-stack Java development with Vue 2/3 front-end suite; hands-on examples and source code analysis for Spring, Spring Boot 2/3, and Spring Cloud.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.