Spring-Boot-Admin未加载“管理"页面&已为登录页面加载用户界面 [英] Spring-Boot-Admin is not loading the Admin page & UI is loaded for login page

查看:128
本文介绍了Spring-Boot-Admin未加载“管理"页面&已为登录页面加载用户界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关Spring Boot 1.5版本的Spring Boot Admin的帮助 问题:我不喜欢github中提供的创建Spring Boot Admin App的步骤 然后将@EnableAdminServer批注应用于Startup类 我可以看到登录页面正在加载,但是样式没有加载,并且在输入用户名和密码后单击登录按钮后,它不会重定向到Spring Boot Admin主页.

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>
    <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启动文件如下所示:

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();
        }
    }

}

截屏:

推荐答案

让您的SecurityConfig如下所示即可.

  @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();
    }
}

这篇关于Spring-Boot-Admin未加载“管理"页面&amp;已为登录页面加载用户界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆