Swagger-ui with Spring security

后端 未结 3 1817
遇见更好的自我
遇见更好的自我 2021-01-23 07:21

I have a simple REST application with authentication service. I tried to add swagger and swagger-ui to it, but I can only see my endpoints in /v2/api-docs. In

3条回答
  •  悲哀的现实
    2021-01-23 08:11

    For me, there was no issue in traditional Weblogic deployment without any mention of @Override public void configure(WebSecurity web) throws Exception ...Only @Override protected void configure(HttpSecurity http) throws Exception was enough and UI was visible on swagger.

    But the same code was not working on Apache Tomcat server so below code was needed ,

    @Override public void configure(WebSecurity web) throws Exception { web.ignoring().mvcMatchers(HttpMethod.OPTIONS, "/**"); // ignore swagger web.ignoring().mvcMatchers("/swagger-ui.html/**", "/configuration/**", "/swagger-resources/**", "/v2/api-docs","/webjars/**"); }

    /webjars/** being missing in answer by AokoQin.

    Answering here because I don't faced any issues on Weblogic without above code but only Tomcat. I already had resources added via ResourceHandlerRegistry in mvc config.

提交回复
热议问题