我创建了一个简单的Springboot应用程序,它运行在我的本地主机端口编号9091上,返回"Hello world!“当调用http://localhost:9091/helloWorld url时。
下面是我的Springboot主类和控制器类的代码片段
@SpringBootApplication
public class HelloWorldApplication {
public static void main(String[] args) {
SpringApplication.run(HelloWorldApplication.class, args);
}
}
@RestController
public class HelloWorldController {
@GetMapping(value="/helloWorld")
public String helloWorld() {
return "Hello world!!!!";
}
}下面是我的pom.xml中的依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.3</version>
</dependency>我还可以使用下面的url http://localhost:9091/swagger-ui/index.html访问Springboot项目的swagger

我已经使用下面的yaml文件配置将这个Springboot应用程序部署到我的k8s集群中
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: moviepopcorn/hello_world:0.0.1
ports:
- containerPort: 9091
imagePullPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: hello-world
spec:
type: NodePort
selector:
app: hello-world
ports:
- port: 9091
targetPort: 9091
nodePort: 30001我还可以使用下面的url :访问:

但是,当我试图使用下面的url http://192.168.254.94:30001/swagger-ui/index.html访问Springboot的swagger-ui时,我会看到下面的Whilelabel错误页面

当我使用集群主节点ip访问我的springboot应用程序时,请您帮助我理解是什么导致了这个白标签错误页问题吗?
发布于 2022-02-16 02:11:49
我找到了解决办法。我刚刚在pom.xml中添加了以下依赖项
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webflux-ui</artifactId>
<version>1.6.3</version>
</dependency>https://stackoverflow.com/questions/71133895
复制相似问题