这不会是OP的问题,但是对于任何尝试一切都没有成功的人来说:
我有类似的症状。每当我经过建mvn clean
,也不会找到log
,或getXYZ()
,或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
方法在静态字段上进行了注释。
Spring 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!");
}
}