intellij-idea - Log4j2 Annotation 从 Intellij 获取错误

标签 intellij-idea gradle groovy log4j2

在 Intellij 中将 Log4j2 用于 groovy/gradle 项目时,日志显示为红色,好像注入(inject)不起作用。 Gradle 运行和构建,但 IntelliJ 中的每个文件都显示令人讨厌的错误。

依赖关系

compile 'org.codehaus.groovy:groovy-all:2.4.4'
compile 'org.apache.logging.log4j:log4j-api:2.5'
compile 'org.apache.logging.log4j:log4j-core:2.5'

来源
import groovy.util.logging.Log4j2
@Log4j2
class TestLog4j2 {
    public static void log(String message) {
        log.error(message)

来自 log.error 的日志显示为红色并显示错误,无法解析符号“日志”
log4j2.xml 文件位于类路径中并且可以工作。
@Log4j 甚至 @Slf4j 都可以工作
使用 IntelliJ 15.03 构建 IU-143.1821
项目正在使用 Groovy 2.4.4 和 Gradle 2.3

有人想吗?

最佳答案

使用 groovy 的 @Log4j2 时出现此错误注解。

solution是在 gradle 中排除以下模块:

configurations.all {
  exclude module: 'log4j-to-slf4j'
}

关于intellij-idea - Log4j2 Annotation 从 Intellij 获取错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35466248/

相关文章:

intellij-idea - IntelliJ IDEA CE for 和 FTC Robotics Simulator 中的导入问题

eclipse - 我无法让 tomcat/jax-rs 和 maven 在同一个 IDE 的同一个项目中工作

java - Gradle、JavaEE 和 Netbeans 集成

java - ehcache session 范围在 grails 中

spring - 我的api/登录帖子在Spring安全的Grails 3上遭到未授权

JAVA:使用IntelliJ IDEA在JSP中显示mysql数据

gradle - 告诉 IntelliJ 为 Gradle 制作 1 个单个模块而不是多个模块

android - 无法将 native 打包为 apk 应用程序 :validateSigningRelease app:transformNativeLibsWithStripDebugSymbolForRelease erros

android - 使用 gradlew 从 Android Studio VS 运行时,仪器单元测试有不同的结果

grails - Grails Executor 插件出错,未找到 bean "persistenceInterceptor"