error message
Localization of the problem
In general, when using Spring Boot alone, the file will not take effect, that is, there is no little green leaf icon; if you use the Spring Cloud components to take effect, you need to introduce the spring-cloud-commons-dependencies package dependencies. In addition, the load order of .
settle (a dispute)
Option 1, which can be introducedSpring Cloud
A component of theEureka
alternativelyFeign
etc., because it containsspring-cloud-commons-dependencies
Dependency.
<dependency> <groupId></groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency>
Option 2, separate introductionspring-cloud-commons-dependencies
dependencies
<dependency> <groupId></groupId> <artifactId>spring-cloud-commons-dependencies</artifactId> <version>${}</version> </dependency>
Expansion:
springboot can't read configuration item problem
Today when building the project, using springboot 2.4.6 version, and then add the configuration file suddenly found that has been unable to read the configuration. Previously in the project dependency vulnerability version of the upgrade have a brief understanding of it.
Analysis of causes
Simply put: Since bootstrap is an add-on brought by spring cloud, you need to have some cloud-related configurations to be able to read it properly, otherwise you will only read it.
cure
If the springboot version is lower than 2.4.0, you need to add a dependency to the pom of the startup class
<!-- spring cloud,on the basis ofspring cloudJust read it. --> <dependency> <groupId></groupId> <artifactId>spring-cloud-context</artifactId> </dependency>
If springboot is older than 2.4.0, add a dependency to the pom for the starter class
<dependency> <groupId></groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> </dependency>
For example, if I use version 2.4.6 here, then the corresponding dependencies to be added are:
<!-- spring cloud,on the basis ofspring cloudJust read it. --> <dependency> <groupId></groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> <version>3.0.3</version> </dependency>
At this point, both the startup banner and @value("${}") can read the values in the file.
Above is SpringBoot can not recognize the solution to the problem of small green leaves in detail, more information about SpringBoot can not be recognized please pay attention to my other related articles!