codecentric / spring-boot-admin

Admin UI for administration of spring boot applications
Apache License 2.0
12.31k stars 3.07k forks source link

documentation: Application main class in getting-started.html #3291

Closed belingueres closed 4 months ago

belingueres commented 4 months ago

Spring Boot Admin Server information

Client information

Description

I had a hard time configuring Security as in the documentation example.

In the https://docs.spring-boot-admin.com/current/getting-started.html:

The spring boot app main class is defined as:

@Configuration
@EnableAutoConfiguration
@EnableAdminServer
public class SpringBootAdminApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootAdminApplication.class, args);
    }
}

but in order for the app to recognize the security config I needed to change @Configuration for @SpringBootApplication:

@SpringBootApplication
@EnableAutoConfiguration
@EnableAdminServer
public class App {

  public static void main(String[] args) {
    SpringApplication.run(App.class, args);
  }

}
erikpetzold commented 4 months ago

Hi @belingueres ,

the getting started docs contain a minimal configuration, but htere is also a grey box below pointing out that there is security in the servlet sample, which imports the security config in the Application class: @Import({ SecurityPermitAllConfig.class, SecuritySecureConfig.class, NotifierConfig.class }).

But we agree that these things will be much simpler with @SpringBootApplication, we will try to update the samples and the docs.

belingueres commented 4 months ago

That seems to be the case: adding the @SpringBootApplication seems to auto-scan for the @Configuration classes. Otherwise we have to explicitly @Import each one of them.

erikpetzold commented 4 months ago

The problem is that autoscanning finds too many configurations as the samples are in the same package as the admin itself. This will be changed here: #3297