Live Documentation Section: 7.2.8. Type-safe Configuration Properties -> Using @ConfigurationProperties-annotated types

Details

Code snippet in the linked section uses data type SomeProperties. Other subsections of 7.2.8 (both before and after the mentioned subsection) define a properties class called MyProperties (first example snippet here):

@ConfigurationProperties("my.service")
public class MyProperties {

    private boolean enabled;

    private InetAddress remoteAddress;

    private final Security security = new Security();

    // getters / setters...

    public static class Security {

        private String username;

        private String password;

        private List<String> roles = new ArrayList<>(Collections.singleton("USER"));

        // getters / setters...

    }

}

Issue

The properties type given in the subsection code example (provided below) appears to exhibit the same structure as the above example, but is a data type not yet seen (SomeProperties). This reduces coherency of the section. When reading, I had to go back to check if I had missed something.

import org.springframework.stereotype.Service;

@Service
public class MyService {

    private final SomeProperties properties;

    public MyService(SomeProperties properties) {
        this.properties = properties;
    }

    public void openConnection() {
        Server server = new Server(this.properties.getRemoteAddress());
        server.start();
        // ...
    }

    // ...

}

Proposed Solution

git clone git@github.com:spring-projects/spring-boot.git
cd spring-boot/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/externalconfig/typesafeconfigurationproperties/usingannotatedtypes/

# replace `SomeProperties` with `MyProperties` in both java source files (and remove sed backups)
sed -i.bkp 's/SomeProperties /MyProperties /g' MyService.java SomeProperties.java && rm *.java.bkp

# rename SomeProperties.java to MyProperties.java
git mv {Some,My}Properties.java

I like this approach because it doesn't require any changes to the external-config.adoc, and doesn't reference anything external.

Comment From: snicoll

Closing in favor of PR #32644