Skip to content

Investigate why code sample in reference doc fails checkArchitectureMain task #48216

@ChildrenGreens

Description

@ChildrenGreens

Description

When building the spring-boot-docs module in Spring Boot 4.0.0 using JDK 25, the task:

:documentation:spring-boot-docs:checkArchitectureMain

fails due to an architecture rule violation triggered by one of the documentation sample classes.

The build output shows:

Execution failed for task ':documentation:spring-boot-docs:checkArchitectureMain'.
> Architecture check failed. See '.../spring-boot/documentation/spring-boot-docs/build/checkArchitectureMain/failure-report.txt' for details.

The generated failure-report.txt contains:

Architecture Violation [Priority: MEDIUM] - Rule 'members that aren't default constructors and aren't constants and don't override public methods should not be public' was violated (1 times):
Method <org.springframework.boot.docs.features.developingautoconfiguration.conditionannotations.classconditions.MyAutoConfiguration$SomeServiceConfiguration.someService()> has modifier PUBLIC in (MyAutoConfiguration.java:38)

This means the method someService() inside the documentation sample class MyAutoConfiguration$SomeServiceConfiguration is declared public, which violates the Spring Boot architecture rule disallowing public members that are not constructors, constants, or overriding methods.

Steps to Reproduce

  1. Clone Spring Boot:

    git clone https://github.com/spring-projects/spring-boot
    cd spring-boot
  2. Build the documentation module:

    ./gradlew :documentation:spring-boot-docs:build

    or run the architecture check directly:

    ./gradlew :documentation:spring-boot-docs:checkArchitectureMain
  3. The task fails with the architecture violation described above.

Expected Behavior

The spring-boot-docs module should build successfully.
Documentation sample code should comply with Spring Boot’s architecture rules, meaning methods that:

  • are not default constructors,
  • are not constants,
  • and do not override public methods

should not be declared public.

Actual Behavior

The architecture check fails because someService() in:

org.springframework.boot.docs.features.developingautoconfiguration.conditionannotations.classconditions.MyAutoConfiguration$SomeServiceConfiguration

is declared as public, violating the architecture rule.

Environment

Component Value
Spring Boot version 4.0.0
Module documentation/spring-boot-docs
JDK 25
OS macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions