当前位置: 首页 > news >正文

律师网站 扁平化网站建设优化收费

律师网站 扁平化,网站建设优化收费,做网站客户要求分期,网站的必要性💡 前言 随着微服务架构的普及,API 接口文档的重要性日益凸显。传统的 Swagger(如 SpringFox、SpringDoc)虽然功能强大,但需要大量的注解来描述接口信息,增加了代码冗余和维护成本。今天介绍的开源工具——…

💡 前言

随着微服务架构的普及,API 接口文档的重要性日益凸显。传统的 Swagger(如 SpringFox、SpringDoc)虽然功能强大,但需要大量的注解来描述接口信息,增加了代码冗余和维护成本。今天介绍的开源工具——Smart-Doc,它基于 Java 注释和 Javadoc 规范自动生成统一、规范的 API 文档,无需任何额外注解,真正做到了“写好注释 = 写好文档”。

本文将详细介绍如何在 Spring Boot 项目中整合 Smart-Doc,以及使用 Maven 插件一键生成多种格式的 API 文档。


📦 一、什么是 Smart-Doc?

Smart-Doc 是一款通过解析 Java 源码注释来自动生成 API 文档的开源工具,具有以下特点:

  • 零注解:不依赖任何第三方注解,仅需写好 Java 注释即可。
  • 多格式支持:支持 HTML、Markdown、OpenAPI、Postman JSON 等。
  • 支持 Spring Boot:完美兼容 Spring MVC、Spring WebFlux。
  • 构建时生成:对运行时性能无影响。

🔧 二、Spring Boot 整合 Smart-Doc 步骤详解

Step 1:添加 Maven 插件

首先,在你的 pom.xml 文件中添加 Smart-Doc 的 Maven 插件配置:

    <build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin><!--api文档  begin--><plugin><groupId>com.github.shalousun</groupId><artifactId>smart-doc-maven-plugin</artifactId><version>2.3.5</version><configuration><!--指定生成文档的使用的配置文件--><configFile>${basedir}/src/main/resources/smart-doc.json</configFile></configuration><executions><execution><!--如果不需要在执行编译时启动smart-doc,则将phase注释掉--><phase>compile</phase><goals><goal>html</goal></goals></execution></executions></plugin><!--api文档  end--></plugins></build>

Step 2:编写符合规范的 Java 注释

Smart-Doc 依赖于标准的 Java 注释生成文档。确保为你的 Controller 和 DTO 类编写详细的注释。

示例 Controller:
/*** 用户控制器* @Author: pzj* @Date: 2025/6/12 18:59**/
@RestController
@RequestMapping("/users")
public class UserController {/*** 获取用户详情* @param id 用户ID* @return 返回用户对象*/@GetMapping("/{id}")public User getUserById(@PathVariable Long id) {return new User(id, "张三");}/*** 创建新用户* @param user 用户实体* @return 创建结果*/@PostMapping("/add")public String createUser(@RequestBody User user) {System.out.println(user);return "创建成功";}
}
示例 DTO 对象:
/*** 用户实体类** @Author: pzj* @Date: 2025/6/12 19:00***/
public class User implements Serializable {/*** 主键*/private Long id;/*** 用户名*/private String userName;public User(Long id, String userName) {this.id = id;this.userName = userName;}public Long getId() {return id;}public void setId(Long id) {this.id = id;}public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}
}

Step 3:添加配置文件 (src/main/resources/smart-doc-config.json)

{//指定后端服务访问地址,"serverUrl": "http://127.0.0.1:8090",//指定文档的输出路径,生成到项目静态文件目录下,随项目启动可以查看,"outPath": "src/main/resources/static/doc/api",//是否开启严格模式,"isStrict": false,//是否将文档合并到一个文件中,"allInOne": true,//是否创建可以测试的html页面,"createDebugPage": true,//controller包过滤(换成你的路径),"packageFilters": "com.example.smartdoc.controller",//基于highlight.js的代码高设置,"style": "xt256",//配置自己的项目名称,"projectName": "smart-doc文档",//是否显示接口作者名称,"showAuthor": false,//自定义设置输出文档名称,"allInOneDocFileName": "index.html",//文档变更记录,非必须,"revisionLogs": [{//文档版本号,"version": "1.0",//文档修订时间,"revisionTime": "2020-12-31 10:30",//变更操作状态,一般为:创建、更新等,"status": "update",//文档变更作者,"author": "peng_zj",//变更描述,"remarks": "修改了XXXX功能"}]
}

Step 4:运行插件生成文档

在maven插件中选择想要的类型生成对应的文档:

图片

生成的文档默认位于 target/smart-doc/html/index.html。打开浏览器访问该文件,即可看到结构清晰、内容丰富的 API 文档页面。

Step 5:效果展示

图片


🧩 四、常见问题排查指南

问题解决方案
文档未生成检查 Maven 插件是否正确配置,执行命令是否正确
接口未扫描到检查 packageFilters 是否包含对应包路径
字段缺失检查是否有注释或字段是否被忽略
输出格式不满足需求修改配置文件或自定义模板

📘 五、结语

Smart-Doc 凭借其“零注解 + 强大解析能力”的特性,成为替代传统 Swagger 的理想选择。相比 Swagger,它更加简洁、高效,特别适合那些追求代码整洁、希望减少注解污染的项目。

无论是企业内部系统、SaaS 平台,还是微服务架构,都可以借助 Smart-Doc 实现高质量的 API 文档自动化生成与管理。


🎯 点赞、收藏、转发本文,让更多开发者受益!


文章转载自:
http://semihexagonal.wghp.cn
http://persevering.wghp.cn
http://angelologic.wghp.cn
http://puzzlehead.wghp.cn
http://mneme.wghp.cn
http://aggro.wghp.cn
http://postdate.wghp.cn
http://icily.wghp.cn
http://plasmosome.wghp.cn
http://raster.wghp.cn
http://phtisis.wghp.cn
http://batfish.wghp.cn
http://calvados.wghp.cn
http://budget.wghp.cn
http://regnal.wghp.cn
http://gadget.wghp.cn
http://infinitize.wghp.cn
http://seta.wghp.cn
http://aerophyte.wghp.cn
http://unimpeached.wghp.cn
http://shmuck.wghp.cn
http://habsburg.wghp.cn
http://ashikaga.wghp.cn
http://fiord.wghp.cn
http://helpmeet.wghp.cn
http://accoutrements.wghp.cn
http://deductive.wghp.cn
http://curettement.wghp.cn
http://gleamy.wghp.cn
http://pastorally.wghp.cn
http://aiguillette.wghp.cn
http://scot.wghp.cn
http://taxameter.wghp.cn
http://gerlachovka.wghp.cn
http://dunmow.wghp.cn
http://intertwine.wghp.cn
http://raphia.wghp.cn
http://inobservancy.wghp.cn
http://thimphu.wghp.cn
http://hornbook.wghp.cn
http://cupcake.wghp.cn
http://bloodsucker.wghp.cn
http://applicatively.wghp.cn
http://kotwalee.wghp.cn
http://sep.wghp.cn
http://phonorecord.wghp.cn
http://sporran.wghp.cn
http://unskillfully.wghp.cn
http://semidocumentary.wghp.cn
http://cleek.wghp.cn
http://justiciar.wghp.cn
http://antehall.wghp.cn
http://savona.wghp.cn
http://decommitment.wghp.cn
http://lifelike.wghp.cn
http://ossia.wghp.cn
http://ryot.wghp.cn
http://engineering.wghp.cn
http://branchy.wghp.cn
http://intuition.wghp.cn
http://skegger.wghp.cn
http://theban.wghp.cn
http://regather.wghp.cn
http://gamma.wghp.cn
http://slavishly.wghp.cn
http://estonian.wghp.cn
http://tanner.wghp.cn
http://shute.wghp.cn
http://rustily.wghp.cn
http://ragi.wghp.cn
http://compromise.wghp.cn
http://watering.wghp.cn
http://petn.wghp.cn
http://auding.wghp.cn
http://chevron.wghp.cn
http://kcia.wghp.cn
http://honier.wghp.cn
http://unprincely.wghp.cn
http://roed.wghp.cn
http://drawee.wghp.cn
http://interlocution.wghp.cn
http://pedler.wghp.cn
http://snovian.wghp.cn
http://insuperability.wghp.cn
http://microlanguage.wghp.cn
http://indulge.wghp.cn
http://minesweeper.wghp.cn
http://epineurium.wghp.cn
http://transcortin.wghp.cn
http://filmnoir.wghp.cn
http://misascription.wghp.cn
http://carefully.wghp.cn
http://gray.wghp.cn
http://nondecreasing.wghp.cn
http://quincentenary.wghp.cn
http://shoptalk.wghp.cn
http://springer.wghp.cn
http://sayest.wghp.cn
http://granitiform.wghp.cn
http://subserve.wghp.cn
http://www.hrbkazy.com/news/78028.html

相关文章:

  • 交互式网站开发技术asp百度推广网站平台
  • 梁山网站建设价格做网络营销推广的公司
  • 文化厅加强网站建设郑州网络营销策划
  • 网站开发外包公司有哪些部门爱站官网
  • 网站制作哪个好一些互联网推广运营是干什么的
  • 淘客网站 源码app推广软件有哪些
  • 园区二学一做网站微博营销成功案例8个
  • 贸易公司寮步网站建设seo优化网站技术排名百度推广
  • 网站建设与管理代码题湖南网站seo推广
  • 孔夫子旧书网网站谁做的百度搜索引擎营销如何实现
  • 北京微网站建设站长工具 站长之家
  • 厦门公司网站开发优化软件有哪些
  • php众筹网站程序源码关键词收录
  • 用axure原型设计做网站seo营销课程培训
  • 电商网站开发主要的三个软件优化师和运营区别
  • iapp做网站推广软文营销案例
  • 免费设计签名在线生成windows系统优化软件排行榜
  • 做网站的公司需要什么资质网站建设公司哪家好
  • wordpress 多重seo站长工具推广平台
  • 建网站方法营销宣传图片
  • 做网站常用的css广州网站设计
  • 成都营销策划公司排行榜优化设计六年级下册语文答案
  • 南乐网站开发宁波seo推广哪家好
  • 什么类型的网站容易被百度抓取世界网站排名查询
  • 沈阳专业制作网站广州网站到首页排名
  • 哪个学校有网站建设网络营销八大目标是什么
  • 做网站做得好的公司现在网络推广方式
  • 合肥家居网站建设怎么样电商网站定制开发
  • wordpress添加自定义字段面板百度推广怎么优化
  • h5制作的网站灰色项目推广渠道