0

I have a problem with updating Log4j versions. In my pom.xml file I updated the version like this:

<properties>
        // other stuff //
        <org.apache.logging.log4j.version>2.16.0</org.apache.logging.log4j.version>
    </properties>

But in the dependencies:

<dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>{org.apache.logging.log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>{org.apache.logging.log4j.version}</version>
        </dependency>

The versions throw an error that it's override to 2.11.1 from a BOM file. Where can I update my pom to import a 2.16.0 version BOM file?

Kerk
  • 283
  • 1
  • 4
  • 24

3 Answers3

1

I guess you can try this to override spring-boot bom.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-bom</artifactId>
            <version>2.16.0</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
        ... other dependencies including spring-boot-dependencies
    </dependencies>
</dependencyManagement>
Sukhmeet Sethi
  • 616
  • 5
  • 14
1

NOT GOOD/no effect(maybe for log4j1):

<org.apache.logging.log4j.version>2.16.0</org.apache.logging.log4j.version>

Better

(for spring-boot-parent-based [2-2.6.1]/spring-dependeny-managed):

<log4j2.version>2.16.0</log4j2.version>

;)

Link

xerx593
  • 12,237
  • 5
  • 33
  • 64
  • I have some other errors after changing the tags. I got this in my plugins section of pom: ```'build.pluginManagement.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-surefire-plugin``` – Kerk Dec 17 '21 at 08:45
  • this (latest) is an "easy fix"! (just read the error message: "found duplicate declaration of plugin ..surefire..") – xerx593 Dec 17 '21 at 08:47
  • sry copied in wrong one, I managed that one, I have trouble with this one: ```Plugin could not be resolved. Ensure the plugin's groupId, artifactId and version are present. Additional information: Plugin org.jacoco:jacoco-maven-plugin:0.8.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.jacoco:jacoco-maven-plugin:jar:0.8.3``` – Kerk Dec 17 '21 at 08:57
  • uff, this is harder (& probably not related) [see here](https://stackoverflow.com/q/6642146/592355) ..it could be (temporal/permanent) network issue, or something with your "company (maven) repository"...if all fails: just download it (to local maven repo (`~/.m2/repository`)) – xerx593 Dec 17 '21 at 09:08
0

So both answers helped me out finding the solution for my problem. The problem was that in my dependency I didn't put a $ sign for my version tag. So with this line of code it works now: <version>${org.apache.logging.log4j.version}</version>

Kerk
  • 283
  • 1
  • 4
  • 24