2016-12-02 22 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; 

問題解決了。