maven构建报错:Unable to load the mojo 'install' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-install-plugin:2.4'

发布时间 2023-06-20 11:37:43作者: buguge

项目在执行maven clean install时,报错:

Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project sby-component-all: Execution default-install of goal org.apache.maven.plugins:maven-install-plugin:2.4:install failed: Unable to load the mojo 'install' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-install-plugin:2.4'

 

使用mvn dependency:tree命令查看项目对maven-install-plugin的依赖,并未发现。看来是间接依赖,例如在maven-plugin里(注意到在构建过程中有如下log)

Downloading: http://192.168.40.38:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-plugins/12/maven-plugins-12.pom
Downloaded: http://192.168.40.38:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-plugins/12/maven-plugins-12.pom (12 KB at 279.8 KB/sec)

Downloading: http://192.168.40.38:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-plugins/16/maven-plugins-16.pom
Downloaded: http://192.168.40.38:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-plugins/16/maven-plugins-16.pom (13 KB at 308.4 KB/sec)

Downloading: http://192.168.40.38:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-plugins/27/maven-plugins-27.pom
Downloaded: http://192.168.40.38:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-plugins/27/maven-plugins-27.pom (12 KB at 63.8 KB/sec)

 

难道是maven-install-plugin:2.4版本的问题吗?于是,显式指定项目的maven-install-plugin的版本为2.5.2, 然并卵。

最后,发现项目的plugins里有个smart-doc-maven-plugin,就是它产生的maven构建冲突。临时把它注释掉就可以正常构建了。
至于怎么解决smart-doc-maven-plugin的并存问题,后续再做研究。


========================================================
smart-doc-maven-plugin是什么?如下介绍来着ChatGPT↓↓↓↓

Smart-doc-maven-plugin 是一款 Maven 插件,用于自动生成 API 文档。它可以通过分析 Java 代码中的注释和源码来自动生成 RESTful API 文档,支持多种文档格式(如 Markdown、HTML、Swagger 等),并且可以与 Spring Boot 等框架无缝集成。以下是 Smart-doc-maven-plugin 的主要特点和好处:

1. 自动生成 API 文档:Smart-doc-maven-plugin 可以自动解析 Java 代码中的注释和源码,并将其转换为 RESTful API 文档。这可以大大减少手动编写 API 文档的工作量,提高开发效率。

2. 多种文档格式支持:Smart-doc-maven-plugin 支持多种文档格式,包括 Markdown、HTML、Swagger 等。这使得生成符合不同需求的 API 文档变得容易。

3. 与框架无缝集成:Smart-doc-maven-plugin 可以与 Spring Boot 等框架无缝集成,只需要在 Maven pom.xml 文件中添加插件配置即可。这使得在现有项目中添加 API 文档功能变得容易。

4. 支持自定义配置:Smart-doc-maven-plugin 允许用户通过配置文件进行自定义配置,例如指定要生成的文档格式、指定文档输出路径等。

5. 支持国际化:Smart-doc-maven-plugin 支持国际化,可以将生成的 API 文档翻译为多种语言,方便不同国家和地区的开发者使用和阅读。

总的来说,Smart-doc-maven-plugin 是一款非常实用的 Maven 插件,可以自动生成 RESTful API 文档,减少手动编写 API 文档的工作量,提高开发效率。同时,它支持多种文档格式、与框架无缝集成、支持自定义配置和国际化等特性,使其成为一款非常成熟、灵活和方便使用的 API 文档生成工具。