问题
I need help with Spring Boot Admin with version Spring Boot 1.5 Problem: I fallowed the steps provided in github to create Spring Boot Admin App And I applied the @EnableAdminServer annotation to my Startup class I can see the login page loading but the styles are not loading and once i hit the login button after entering the username and password it's not redirecting to Spring Boot Admin home page.
Dependencies used are below:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-login</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
Java Startup file looks like below:
@EnableAdminServer
@Configuration
@SpringBootApplication
public class SpringBootAdminApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootAdminApplication.class, args);
}
@Configuration
public static class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin().loginPage("/login.html").loginProcessingUrl("/login").permitAll();
http.logout().logoutUrl("/logout");
http.csrf().disable();
http.authorizeRequests()
.antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**")
.permitAll();
http.authorizeRequests().antMatchers("/**").authenticated();
http.httpBasic();
}
}
}
Screenshot:
回答1:
Remove the spring-boot-admin-server-ui-login. Then it will load the correct login.htm with related css files.
Remove this and rebuild and run.
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui-login</artifactId>
<version>1.5.1</version>
</dependency>
回答2:
Have your SecurityConfig
like below should work.
@Configuration
public static class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login.html").loginProcessingUrl("/login").permitAll()
.and()
.logout().logoutUrl("/logout")
.and()
.httpBasic();
}
}
来源:https://stackoverflow.com/questions/51786821/spring-boot-admin-is-not-loading-the-admin-page-ui-is-loaded-for-login-page