2016-12-02 27 views
-1

上实现MDC使用春BOM用法错误

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

现在我打算使用

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

但代码这是以前的工作:

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

上面一行是给出错误:

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

请提出建议。

+0

你仍然需要依赖。导入应该放在'dependencyManagmenet'部分。参见http://platform.spring.io/platform/另外'MDC'与'spring-webmvc'无关,它可能是一个log4j(或slf4j)类。 –

+0

BOM依赖关系仅在“依赖管理”部分中。我加了'log4j-over-slf4j'依赖性,同样的错误。 – Raghuveer

+0

执行'mvn dependency:tree'并检查差异。 –

回答

0

由于升级,MDC依赖项已升级且方法签名已更改。所以我基本上改变了变量的实现从

private final Map<?, ?> parentContext; 

private final Map<String, String> parentContext; 

问题解决了。