How to fix Commons Lang “Package Does Not Exist” Error

If you’re here, then you probably were met with a Java stack trace that has lines similar to this in it:
package org.apache.commons.lang does not exist...static import only from classes and interfaces
I saw this in a few Spring Boot applications with Maven, and the good news is that the fix should be easy.
The fix
In your source code, do a global search for the following import
prefix:
import static org.apache.commons.lang
Then, replace all instances of that with the following:
import static org.apache.commons.lang3
Example
Let’s say a program has the following Commons Lang import
statements:
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isNotBlank;
Simply put a 3
after lang
. Your final import
statements will then look like this:
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
Your app should now build.
Why?
Basically, Commons Lang 3.x
brought in this new package naming with the 3
in lang3
. More details on that as well as what else changed from 2.x
to 3.x
are here.