我收到此弹出窗口,http://localhost:8080/swagger-ui.html。 首先我以为这是我的数据库或 GIT 的密码。 但以上均不被接受。
package com.gabor.usermanagment.configs;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.gabor.usermanagment.api"))
.paths(regex("/customerapi.*"))
.build()
.apiInfo(metaData());
}
private ApiInfo metaData() {
ApiInfo apiInfo = new ApiInfo(
"Spring Boot REST API",
"Spring Boot REST API for Online Store",
"1.0",
"Terms of service",
new Contact("John Thompson", "https://springframework.guru/about/", "[email protected]"),
"Apache License Version 2.0",
"https://www.apache.org/licenses/LICENSE-2.0");
return apiInfo;
}
}
我遇到了同样的问题,但是这个链接确实有帮助。
我已经正确配置了我的应用程序,但后来我开始搞乱软件包。在我的日志中我可以看到这样的内容:
Using generated security password: 0768c114-ea85-4cd2-8cc0-626954b6557a
在我提供用户名:用户和这些生成的密码后,openapi打开但没有文档。
我的模块很少,我的应用程序核心模块位于包中:com.example.app.myapp
但是我的安全性和 openapi 配置位于包中:com.example.app
所以就我而言,隐藏在安全措施后面的软件包存在问题。
我希望有人觉得这很有用。
使用Tomcat启动Spring Boot时的用户名和密码是什么?
在进一步研究解决方案后,我找到了它。这个问题已经解决了。