Maven import static constant cannot find symbol

Suppose you have a class with constants:

package org.example;

public class Constants {
    public static final String MY_CONSTANT = "value";   

And you made the static import of this constant in another class:

package org.example;

import static org.example.Constants.MY_CONSTANT;

public class MyOtherClass {

Everything looks good, and IDEA does not show any mistakes (in fact, there are really no errors in code). But Maven suddenly failed building project with cannot find symbol error.

This situation can arise because there are too many constants declared in the original Constants class. It is not entirely clear what is going on, but if you change this static import in the MyOtherClass class this way:

import static org.exampe.Constants.*;

The error will go away.

If you still have any questions, feel free to ask me in the comments under this article, or write me on

Leave a Reply

Your email address will not be published. Required fields are marked *