这不会是 OP 的问题,但对于尝试一切都没有成功的其他人:
我有类似的症状。每当我在 a 之后构建mvn clean
时,它都不会找到log
, or getXYZ()
, or builder()
, 或任何东西。
[ERROR] symbol: variable log
[ERROR] location: class com.example.MyClass
[ERROR] /Path/To/Some/Java/src/main/com/example/MyClass.java:[30,38] cannot find symbol
[ERROR] symbol: method builder()
[ERROR] location: class com.example.MyClass
在阅读了我能找到的关于 QueryDSL/JPA/Hibernate/Lombok/IntelliJ/Maven 问题的所有答案后,我发现罪魁祸首是在静态字段上注释的方法的单个静态导入@Getter
。
春季 1.15.14.RELEASE,Intellij 2019.1.1
@SpringBootApplication
public class BarApplication implements ApplicationContextAware {
@Getter
private static ApplicationContext applicationContext;
// ... start Spring application, and grab hold of ApplicationContext as it comes past
}
import ...
import static BarApplication.getApplicationContext;
@Slf4j
public class IMakeItAllFail {
public IMakeItAllFail() {
log.info("{}", getApplicationContext());
}
}
@Slf4j
public class Foo {
Foo() {
log.info("I fail to compile but I have nothing to do with the other classes!");
}
}