我正在尝试使用github上的这个工具来分析我的春季引导应用程序的启动时间。这是我的主修课:
@Configuration
@EnableAutoConfiguration
@ComponentScan(lazyInit = true, value = {"com.test.app","com.github.lwaddicor.springstartupanalysis"})
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ApiApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
}
}我的应用程序启动良好,但当我尝试导航到:http://localhost:8080/spring-startup/时,我得到以下消息:
{"status":401,"message":"Authentication failed","errorCode":10,"timestamp":1519416149986}我尝试过像这样编辑安全过滤器:
@EnableWebSecurity
@EnableWebMvc
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(,
"/configuration/ui",
"/configuration/security",,
"/spring-startup",
"/webjars/**");
}
}但那不管用。知道我做错什么了吗?
发布于 2018-02-24 01:01:26
我是通过注释overriden configure方法来实现这一点的。不是最优的,但我只需要在本地运行一次,所以也不需要关闭安全性。
发布于 2018-02-23 22:39:12
我认为仅使用antMatchers()是不够的,因为您只告诉系统哪些资源受到影响,但是您没有指定如何处理这些资源。追加.permitAll(),它应该可以工作。
我用的是这样的东西:
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.antMatchers(HttpMethod.HEAD, "/**").permitAll()
.antMatchers("/v2/api-docs", "/configuration/ui", ...)
.permitAll()
.antMatchers(basePath + "/**").authenticated()
...basePath是到rest的路径,应该对其进行保护。
https://stackoverflow.com/questions/48955601
复制相似问题