我发现了问题的原因-根据以下文档https://docs.spring.io/spring-boot/docs/current-
SNAPSHOT/reference/htmlsingle/与Spring Boot 2
*一起,应按顺序使用以下属性定义应用程序的上下文路径:
server.servlet.context-path= /api
请注意,Spring Boot 1.5。*属性
server.contextPath: /api
没有更多考虑

我发现了问题的原因-根据以下文档https://docs.spring.io/spring-boot/docs/current-
SNAPSHOT/reference/htmlsingle/与Spring Boot 2
*一起,应按顺序使用以下属性定义应用程序的上下文路径:
server.servlet.context-path= /api
请注意,Spring Boot 1.5。*属性
server.contextPath: /api
没有更多考虑