Recently log4j2
has swept most Internet companies, and the upgraded version has become the core task of these two weeks. For what version to upgrade to, the latest version 2.16.0 is the best choice. So how to quickly upgrade, before also gives the Spring project upgraded version of the Boot easiest way .
You only need to use this simple configuration to upgrade all the versions of log4j2 packages.
If this method does not work, pay attention to reload after adding the configuration. In addition, if you are not a Spring Boot project, or log4j2 introduced by other means, you need to deal with it separately, or in the root dependency of your project, directly write the dependency of log4j2 and set the version to 2.16.0, forcing to cover other places Introduced version. With good people, you will gradually become better! Welcome to join the high-quality technical exchange group .
The above configuration is very simple, but some readers still don't know why this is enough:
So, today I will tell you about the principle of this configuration.
Step by step to understand why
Below I will take you step by step to understand this configuration by reading the code to find the source. I hope you can learn this method of exploring the problem yourself in addition to knowing why this problem is through this article.
first step : Observe your pom.xml
, have you found that many dependencies, including non-Spring Boot Starter dependencies, have not written version?
Since it can run without a version, there must be a place to define it! Shift the focus to the parent, it seems that there is a version here!
second step : further look spring-boot-starter-parent
the content of 061c41e7d063e1
After entering, you can see a xml
, which mainly contains content related to build, not dependent information.
third step : Continue to observe spring-boot-starter-parent
, you can see that it also has a parent, so the kid hides so deep! Then continue to look spring-boot-dependencies
the content of 061c41e7d064ac:
After entering, we can see the key points. The version parameters of each component under this Spring Boot version are here:
Searching for log4j2
2.14.1
is used by default in this version:
Continue to search, under the dependencyManagement
node, you can see that the version definitions of each dependency refer to each properties
configured above:
Therefore, when we configure the corresponding properties
in our Spring Boot, we can overwrite the properties
in the parent and implement the version update.
Okay, have you gotten today's little knowledge? If you encounter difficulties in the learning process? You can join our ultra-high-quality Spring technical exchange group , and you will gradually become better when you are with excellent people! More Spring Boot tutorials can be clicked directly! , welcome to collect and forward support!
Welcome to pay attention to my official account: Program Ape DD, to share knowledge and thoughts that can’t be seen elsewhere
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。