springfox-swagger2配置成功但无法访问/swagger-ui.html的解决方法

打开http://localhost:8080/swagger-ui.html#/出现

springfox-swagger2配置成功但无法访问/swagger-ui.html的解决方法

出现的主要原因是:扫描不到swaggerConfig所在的路径,所以需要在主类中添加SwaggerConfig类所在的包的路径

@SpringBootApplication
@ComponentScan("config")
@ComponentScan("controller")
public class DemoApplication {

   public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
   }

}

红色代码为添加的代码,然后运行主类。(如果自己有测试类就直接在测试类中修改)打开网站就好了