文章目录
问题
经过上篇 && 中篇的修改,再次使用mvn clean install尝试下载knife4j的jar包,发现仍然被中止了,仔细查看报错信息,发现了新的错误,基本判断都是细节上的问题。复盘的重要性
xml
D:\develop。。。re\Envi。。ent\jdk\jdk-8u301-windows-x64\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\project\spring_project\lease -Dmaven.home=D:\developerSoftware\Environment\apache-maven-3.6.3 -Dclassworlds.conf=D:\developerSoftware\Environment\apache-maven-3.6.3\bin\m2.conf "-Dmaven.ext.class.path=D:\Common Softwears\IntelliJ IDEA\IntelliJ IDEA 2021.1.1\plugins\maven\lib\maven-event-listener.jar" "-javaagent:D:\Common Softwears\IntelliJ IDEA\IntelliJ IDEA 2021.1.1\lib\idea_rt.jar=62406:D:\Common Softwears\IntelliJ IDEA\IntelliJ IDEA 2021.1.1\bin" -Dfile.encoding=UTF-8 -classpath D:\developerSoftware\Environment\apache-maven-3.6.3\boot\plexus-classworlds-2.6.0.jar;D:\developerSoftware\Environment\apache-maven-3.6.3\boot\plexus-classworlds.license org.codehaus.classworlds.Launcher -Didea.version=2021.1.1 -s D:\developerSoftware\Environment\apache-maven-3.6.3\conf\settings.xml install
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:jar is missing. @ line 20, column 21
[ERROR] 'dependencies.dependency.version' for com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:jar is missing. @ line 15, column 21
@
[ERROR] The build could not read 2 projects -> [Help 1]
[ERROR]
[ERROR] The project com.atguigu:model:1.0-SNAPSHOT (D:\project\spring_project\lease\model\pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:jar is missing. @ line 20, column 21
[ERROR]
[ERROR] The project com.atguigu:web-app:1.0-SNAPSHOT (D:\project\spring_project\lease\web\web-app\pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:jar is missing. @ line 15, column 21
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Process finished with exit code 1
问题分解
发现问题:
xml
[ERROR] 'dependencies.dependency.version' for com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:jar is missing. @ line 20, column 21
[ERROR] 'dependencies.dependency.version' for com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:jar is missing. @ line 15, column 21
@
具体定位:1.\lease\model\pom.xml) has 1 error [ERROR] 'dependencies.dependency.version' for com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:jar is missing. @ line 20, column 21 [ERROR]
2.\lease\web\web-app\pom.xml) has 1 error [ERROR] 'dependencies.dependency.version' for com.github.xiaoymin:knife4j-openapi3-jakarta-spring-boot-starter:jar is missing. @ line 15, column 21 [ERROR]
分析:1.\model\pom.xml
不匹配,未修改。

2.同样原因

尝试
问题再次出现:发现model实体类模块也是需要的。
错误:
[ERROR] /D:/project/spring_project/lease/model/src/main/java/com/atguigu/lease/model/entity/FacilityInfo.java:[9,2] 找不到符号 符号: 类 Schema

添加,再次尝试。

还有问题:程序包org.springdoc.core.models不存在
问题定位:在web模块出的问题

不应该在这个依赖坐标放到web模块下,应该在admin以及app下的pom文件中写入。
web-admin 是子模块,但不会自动继承 dependencies。Maven设计规则。
找不到符号: 类 GroupedOpenApi
package org.springdoc.core.models 不存在
说明 不是 Knife4j 依赖的问题,而是 缺少 springdoc-openapi 依赖。
GroupedOpenApi 这个类其实来自 springdoc,不是 Knife4j。
实体类来源:org.springdoc.core.models.GroupedOpenApi属于:
SpringDoc OpenAPI
解决
在 web-admin/pom.xml 再加:
xml
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.3.0</version>
</dependency>
总结。
修改:
lease pom:
xml
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>
web-admin / web-app:
sql
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.15</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>-->
<!-- <version>1.6.15</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.15</version>
</dependency>
model:
xml
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.15</version>
</dependency>
http://localhost:8080/doc.html#/home
最后,项目还是应匹配版本号,在项目创建时确定好springboot版本号以及对应的依赖版本
切勿有交叉