像苍穹外卖、尚庭公寓这些spring boot项目的静态资源doc.html在哪?我好像没有编写,但是打开网页就有

测试的springboot项目就没有这个欢迎页面

像苍穹外卖、尚庭公寓这些spring boot项目的静态资源doc.html在哪?我好像没有编写,但是打开网页就有

测试的springboot项目就没有这个欢迎页面

关注让【宝码香车】来帮你解答,本回答参考DeepSeek编写,并整理提供。
如果还有疑问可以点击头像关注私信或评论。如果答案让您满意,请采纳、点赞、关注,非常感谢!
根据问题描述,您想了解SpringBoot项目中前端页面的存放位置以及为什么有些项目会自动生成欢迎页面(如doc.html)。以下是详细解答:
SpringBoot的静态资源默认存放在以下位置(按优先级排序):
src/main/resources/META-INF/resources/
src/main/resources/resources/
src/main/resources/static/
src/main/resources/public/
您看到的doc.html是API文档工具自动生成的:
springfox-boot-starter或springdoc-openapi依赖自动生成Knife4j-v4.1.0)<!-- Knife4j示例 -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>4.1.0</version>
</dependency>
可能原因:
@Configuration
@EnableSwagger2WebMvc // 或 @EnableOpenApi
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}

若需要自定义欢迎页,可在src/main/resources/static/下添加:
<!-- index.html示例 -->
<!DOCTYPE html>
<html>
<head>
<title>欢迎页</title>
</head>
<body>
<h1>Hello SpringBoot!</h1>
</body>
</html>
springdoc-openapi-ui或knife4j/v3/api-docs验证是否返回JSON格式的API文档通过以上步骤,您应该能定位到前端页面的存放位置和自动生成文档的原因。