Article Directory
- Project Framework Description
- serial pit
- version match
- Postscript: Don't upgrade the version easily
For some special reasons, it is necessary to use the springboot project to read the bootstrap.yml
configuration. However, after adding the bootstrap dependency package, the problem of matching the versions of springboot, springcloud and knife4j =_=|| This is really a loop. . .
Write an article to record the "happy" mental journey of Lianhuankeng~
Project Framework Description
Project background description:
SpringBoot 2.2.5.RELEASE
knife4j 3.0.3
serial pit
- After introducing the bootstrap pre-startup configuration, the startup fails
- After upgrading the springboot version to 2.6.6 according to the error, the startup failed
- knife4j is not compatible with the springboot version, you need to downgrade the springboot version
- Try to match the versions of the three
Question 1: The springboot project cannot read the bootstrap.yml configuration
The reason for this problem: The SpringBoot project will only recognize the application.* configuration file, and will not automatically recognize the bootstrap.yml
Solution: Add the bootstrap starter dependency in pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.1.1</version>
</dependency>
Question 2: Startup error, springboot and springcloud versions do not match
The error is as follows:
Spring Boot [2.2.5.RELEASE] is not compatible with this Spring Cloud release train
Action:
Consider applying the following actions:
- Change Spring Boot version to one of the following versions [2.6.x, 2.7.x] .
No way, upgrade the springboot version according to the error (preliminary attempt 2.6.6)
Question 3: Startup error Failed to start bean 'documentationPluginsBootstrapper'
The error is as follows:
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'
I searched for related issues on the Internet, reference: the solution to org.springframework.context.ApplicationContextException , and found that the knife4j (swagger) does not match the springboot version, and the springboot version must be reduced! ! !
Another solution: Modify the path matching strategy of springmvc - to be verified
因为Springfox使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher。
#解决:在application.properties里配置
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
version match
springboot与bootstrap(springcloud)
bootstrap (springcloud) version | springboot version |
---|---|
3.0.1 and 3.0.0 | [2.3.x, 2.4.x] |
3.0.3 | [2.4.x, 2.5.x] |
3.1.1 | [2.6.x, 2.7.x] |
final version plan
SpringBoot 2.4.13 + SpringCloud 3.0.1 + knife4j 3.0.3 finally works! ! ! !
Postscript: Don't upgrade the version easily
A bloody lesson, thinking about upgrading knife4j to a larger version to see the new features, the result caused a series of problems~
ps: My knowledge of the framework is still not clear enough, I have to study hard~