java.lang.NoSuchMethodError: org.springframework.util.StringUtil.isEmpty error processing record

java.lang.NoSuchMethodError: org.springframework.util.StringUtil.isEmpty error processing record

background

The jdk used by our company’s old project is 1.6, and the project written by SpringBoot 2.0 needs to be introduced. The minimum requirement for 2.0 is jdk 1.8, and the version conflicts. So decided to talk about SpringBoot downgrade, down to 1.5.9.RELEASE.

problem

Org.springframework.util.StringUtil.isEmpty is reported when using the tool after adding the dependency. Since the introduced tools can be used normally in other projects, it is considered that the downgrade has caused the method to be updated incorrectly. StringUtil is a method in Spring-core, go to the class to take a look.
isEmpty was added since version 3.2.1
The core package integrated by SpringBoot 1.5.9 is 4.3, and this method is also available when you click to open it. In the end, it can only be that the Spring core package in the old project does not have this method. I went and took a look. As expected, the previous project used 3.1.1.
Insert picture description here

solution

The isEmpty method is included in StringUtils in commons-lang3. After using this package, it is used normally.

Still have questions

In this case, if multiple Spring core packages are introduced, how does jdk choose which package to load? Is there a better solution for this situation?

Guess you like

Origin blog.csdn.net/yishifanghua/article/details/113972863