If I add @Constructorbinding to the class, the compiler will tell me an error. I remember in Spring Boot 2.2.x After version, @Constructorbinding can be used instead of setter

package com.example.demo;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
import org.springframework.stereotype.Component;

/**
 *
 * @author James Zow
 * @create 2022/4/4
 */
@Component
@ConfigurationProperties(prefix = "mail")
public class ConfigProperties {

    private String hostName;
    private int port;
    private String from;

    public ConfigProperties(String hostName, int port, String from) {
        this.hostName = hostName;
        this.port = port;
        this.from = from;
    }
    public ConfigProperties() {
    }

    public String getHostName() {
        return hostName;
    }

    public void setHostName(String hostName) {
        this.hostName = hostName;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

}

Comment From: Jzow

I read this #23216 #23172 #23607 , but I still don't quite understand it

Comment From: wilkinsona

As described in the release notes, it's no longer needed and should be removed.