How to overwrite version of spring boot BOM

1k Views Asked by At

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?

3

There are 3 best solutions below

0
On BEST ANSWER

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>

0
On

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>
4
On

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