在父项目里创建common模块
本次使用的是swagger2 的3.9版本,创建common模块来配置swagger是为后续多模块用swagger准备的。
pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>springcloud-eureka</artifactId>
<groupId>com.example</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<modules>
<module>swagger-config</module>
</modules>
<groupId>com.kevin</groupId>
<artifactId>common</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId

本文介绍了如何在SpringBoot项目中实现多模块架构,并使用Swagger2的3.9版本进行API文档管理。首先,在父项目创建common模块,接着在common模块下建立swaggerconfig子模块,用于配置Swagger。然后,在需要使用Swagger的模块添加相关依赖,并在Controller中添加注解。最后,通过访问http://localhost:8761/swagger-ui/index.html或增强版http://localhost:8761/doc.html来查看和使用Swagger-UI。
最低0.47元/天 解锁文章
6033

被折叠的 条评论
为什么被折叠?



