Search code examples
javamaven-3mdc

Spring bom usage error


Previous implementation of MDC used

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${spring.version}</version>
</dependency>

Now am planning to use

<dependency>
    <groupId>io.spring.platform</groupId>
    <artifactId>platform-bom</artifactId>
    <version>2.0.1.RELEASE</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>

But the code which was working previously :

private final Map<?, ?> parentContext; // initialized in constructor
MDC.setContextMap(parentContext);

The above line is giving the error :

The method setContextMap(Map<String,String>) in the type MDC is not applicable for the arguments (Map<capture#5-of ?,capture#6-of ?>)

Kindly suggest.


Solution

  • Due to upgrade the MDC dependency has upgraded and the method signature has changed. So I basically changed the implementation of the variable from

    private final Map<?, ?> parentContext;
    

    to

    private final Map<String, String> parentContext;
    

    Problem solved.