Java 无法在spring引导中禁用安全性

Java 无法在spring引导中禁用安全性,java,spring,spring-mvc,spring-security,spring-boot,Java,Spring,Spring Mvc,Spring Security,Spring Boot,我想在我的应用程序中禁用spring安全性,并在application.yml文件中设置属性security.basic.enable=false security: basic: enabled: false 我使用弹簧启动执行器检查了/env,发现它加载正确:(在第2行) 但是,安全配置仍然有效,我无法访问需要验证的,但我可以访问那些被许可的 这是应用程序类: @SpringBootApplication @MapperScan("team.xuli.toe.dao") pub

我想在我的应用程序中禁用spring安全性,并在application.yml文件中设置属性security.basic.enable=false

security:
  basic:
    enabled: false
我使用弹簧启动执行器检查了/env,发现它加载正确:(在第2行)

但是,安全配置仍然有效,我无法访问需要验证的,但我可以访问那些被许可的

这是应用程序类:

@SpringBootApplication
@MapperScan("team.xuli.toe.dao")
public class ToeServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ToeServerApplication.class, args);}
}
这是securityConfigutaion:

@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfig extends WebSecurityConfigurerAdapter{

  @Override
  protected void configure(HttpSecurity http) throws Exception {
      http.csrf().disable();
      http.httpBasic();
      http.
             authorizeRequests()
             .antMatchers("/hello").permitAll()
             .anyRequest().authenticated();
  }
  @Autowired
  public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
      System.out.println("user added in mem!");
      auth
          .inMemoryAuthentication()
              .withUser("xqf").password("123").roles("ADMIN");
  }
}

如果您需要安全性作为依赖项,但不希望Spring Boot为您配置它,则可以使用此排除:

@EnableAutoConfiguration(exclude = { 
        org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration.class

    })

如果在应用程序中的任何位置使用
@EnableWebSecurity
定义
@Configuration
,它将在Spring Boot中关闭默认的webapp安全设置。

谢谢,我尝试设置属性安全性。忽略=/**并成功。还有一个类似的问题,谢谢,已经解决了。我尝试设置属性安全性。忽略=/**并成功。还有一个类似的问题:
@EnableAutoConfiguration(exclude = { 
        org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration.class

    })