log4j-slf4j-impl不能与log4j-to-slf4j同时存在 – 在将graphql依赖项添加到pom之后。

huangapple go评论88阅读模式
英文:

log4j-slf4j-impl cannot be present with log4j-to-slf4j --- after adding graphql dependency to pom

问题

我正在尝试使用GraphQL并将其集成到我们现有的项目中。由于我们的项目是使用Java和Spring框架的,所以我在遵循这个教程

但是在添加了以下依赖后:

<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-spring-boot-starter</artifactId>
    <version>5.0.2</version>
</dependency>
<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-java-tools</artifactId>
    <version>5.2.4</version>
</dependency>

并且尝试启动项目时,我遇到了错误:

Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl
cannot be present with log4j-to-slf4j

我在这里这里找到了类似的帖子。这些帖子导致我尝试添加排除项,但并没有帮助:

<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-spring-boot-starter</artifactId>
    <version>5.0.2</version>
    <exclusions>
        <exclusion>
            <groupId>log4j-slf4j-impl</groupId>
            <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
            <groupId>log4j-to-slf4j</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>
英文:

Im trying mess around with graph ql and integrating it with our existing project. Im following this tutorial since our project is java with spring framework

but after adding the dependencies

&lt;dependency&gt;
    &lt;groupId&gt;com.graphql-java&lt;/groupId&gt;
    &lt;artifactId&gt;graphql-spring-boot-starter&lt;/artifactId&gt;
    &lt;version&gt;5.0.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;com.graphql-java&lt;/groupId&gt;
    &lt;artifactId&gt;graphql-java-tools&lt;/artifactId&gt;
    &lt;version&gt;5.2.4&lt;/version&gt;
&lt;/dependency&gt;

and trying to start my project i get an error

> Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl
> cannot be present with log4j-to-slf4j

I have found similar post here, and here
Which lead me to attempt to add exclusions but that did NOT help

        &lt;dependency&gt;
		    &lt;groupId&gt;com.graphql-java&lt;/groupId&gt;
		    &lt;artifactId&gt;graphql-spring-boot-starter&lt;/artifactId&gt;
		    &lt;version&gt;5.0.2&lt;/version&gt;
        &lt;exclusions&gt;
            &lt;exclusion&gt;
                &lt;groupId&gt;log4j-slf4j-impl&lt;/groupId&gt;
                &lt;artifactId&gt;*&lt;/artifactId&gt;
            &lt;/exclusion&gt;
            &lt;exclusion&gt;
                &lt;groupId&gt;log4j-to-slf4j&lt;/groupId&gt;
                &lt;artifactId&gt;*&lt;/artifactId&gt;
            &lt;/exclusion&gt;
        &lt;/exclusions&gt;
		&lt;/dependency&gt;

答案1

得分: 1

排除的依赖关系 groupId 似乎不正确。 将被排除的 groupId 更改为 org.apache.logging.log4j 可能会解决您的问题。

英文:

Excluded dependencies groupId seems wrong. Changing excluded groupId's to org.apache.logging.log4j may solve your problem.

答案2

得分: 0

我最终使用了:

<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-java</artifactId>
    <version>5.0.2</version>
</dependency>
英文:

i ended up using

&lt;dependency&gt;
    &lt;groupId&gt;com.graphql-java&lt;/groupId&gt;
    &lt;artifactId&gt;graphql-java&lt;/artifactId&gt;
    &lt;version&gt;5.0.2&lt;/version&gt;
&lt;/dependency&gt;

huangapple
  • 本文由 发表于 2020年9月9日 10:24:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/63803914.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定