Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
允许在没有spring安全认证的情况下使用静态资源_Spring_Spring Boot_Spring Security - Fatal编程技术网

允许在没有spring安全认证的情况下使用静态资源

允许在没有spring安全认证的情况下使用静态资源,spring,spring-boot,spring-security,Spring,Spring Boot,Spring Security,嗨,我在我的web应用程序中集成了spring安全性。我的configure()方法被覆盖为 @Override protected void configure( HttpSecurity http ) throws Exception { http.cors().and().csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, "/rest/auth/**").permitAll()

嗨,我在我的web应用程序中集成了spring安全性。我的
configure()
方法被覆盖为

@Override
protected void configure( HttpSecurity http ) throws Exception
{
    http.cors().and().csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, "/rest/auth/**").permitAll()
            .antMatchers("/resources/static/**")
            .permitAll().antMatchers("/").permitAll().anyRequest().authenticated().and()
            .addFilter(new JWTAuthenticationFilter(authenticationManager()))
            .addFilter(new JWTAuthorizationFilter(authenticationManager()));
}


我的项目结构如图所示。但是spring安全性实际上不允许在没有身份验证的情况下使用资源。在
WebSecurityConfig.java
中,如果删除
.anyRequest().authenticated()
,则允许浏览器呈现
css
js
。如何解决这个问题

/resources/static
可能应该是
/static
/I给出的
/static/**
,它不起作用。您还需要配置
匿名()
以允许匿名访问。您是否尝试过
@Override public void configure(WebSecurity web)抛出异常{web.ignering().antMatchers(“/resources/static/**”);}
@M.Deinum如何配置
匿名()
/resources/static
应该是
/static
/I给定的
/static/**
,它不起作用您还需要配置
匿名()
以允许匿名访问。您尝试过
@覆盖公共无效配置(WebSecurity web)引发异常{web.ignering().antMatchers(“/resources/static/**”);}
@M.Deinum如何配置
匿名()