首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring-Boot-Admin未加载管理页面&已加载登录页面的UI

Spring-Boot-Admin未加载管理页面&已加载登录页面的UI
EN

Stack Overflow用户
提问于 2018-08-10 20:42:54
回答 2查看 3.2K关注 0票数 0

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

使用的依赖项如下:

代码语言:javascript
复制
<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启动文件如下所示:

代码语言:javascript
复制
@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();
        }
    }

}

截图:

EN

回答 2

Stack Overflow用户

发布于 2018-10-15 00:57:52

删除spring-boot-admin-server-ui-login。然后它会用相关的css文件加载正确的login.htm。

删除它,然后重新构建并运行。

代码语言:javascript
复制
    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-server-ui-login</artifactId>
        <version>1.5.1</version>
    </dependency>

票数 1
EN

Stack Overflow用户

发布于 2018-10-15 01:58:13

让你的SecurityConfig像下面这样工作。

代码语言:javascript
复制
  @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();
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51786821

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档