2015-10-27 405 views
0

我無法在Intellij的Java項目中導入一組庫。我正在使用maven來解決依賴關係;是在POM文件的依賴關係如下:Java依賴關係問題(Intellij/Maven)

的pom.xml

... 
<dependencies> 
     <dependency> 
      <groupId>com.google.guava</groupId> 
      <artifactId>guava</artifactId> 
      <version>17.0</version> 
     </dependency> 
     <dependency> 
      <groupId>io.netty</groupId> 
      <artifactId>netty-all</artifactId> 
      <version>4.0.21.Final</version> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.core</groupId> 
      <artifactId>jackson-databind</artifactId> 
      <version>2.3.5</version> 
     </dependency> 
     <dependency> 
      <groupId>com.fasterxml.jackson.dataformat</groupId> 
      <artifactId>jackson-dataformat-xml</artifactId> 
      <version>2.3.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-jdk14</artifactId> 
      <version>1.7.7</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.10</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.antlr</groupId> 
      <artifactId>antlr4-maven-plugin</artifactId> 
      <version>4.2.2</version> 
     </dependency> 
     <dependency> 
      <groupId>org.fiware.kiara</groupId> 
      <artifactId>kiaraparser</artifactId> 
      <version>0.2.0</version> 
     </dependency> 
</dependencies> 
... 

他們成功地包含在類路徑中。然而,當我嘗試在項目中使用它們:

import com.google.common.util.concurrent.ListenableFuture; 
import io.netty.util.concurrent.Future; 
import io.netty.util.concurrent.GenericFutureListener; 

以下錯誤拋出:

Error:(20, 41) java: package com.google.common.util.concurrent does not exist 
Error:(21, 32) java: package io.netty.util.concurrent does not exist 
Error:(22, 32) java: package io.netty.util.concurrent does not exist 
Error:(34, 81) java: cannot find symbol 
    symbol: class ListenableFuture 
Error:(34, 59) java: cannot find symbol 
    symbol: class Future 

該庫是存在於類路徑:

dependencies

爲什麼在構建時不包含在項目中?

編輯#1:

在進口的IntelliJ項目時的具體步驟將在下面進行顯示:

step 1 step 2 step 3 step 4 step 5 step 6 step 7 step 8

執行「文件 - >無效緩存/重新啓動」和「重新導入所有Maven項目」後,錯誤仍然存​​在。這兩個操作後創建的日誌文件內容如here所示。

爲什麼不加載依賴關係?

編輯#2:

繼建議提到here我現在得到類型的錯誤「模塊必須不包含源根的根已經屬於模塊」:

dependencies 1 dependencies 2

+0

有時的IntelliJ有一個問題,當它被導入Maven依賴(你可以通過查看idea.log檢查)當讀出我已經能夠的情況下通過右鍵單擊項目並選擇Maven - > Reimport來通過它。有時我需要做一個文件 - >無效緩存/重新啓動。 – EGHM

+0

我試着做一個無效緩存/重新啓動並重新導入所有的依賴項,但它沒有工作 – Sebi

回答

0

我已經通過打開項目目錄修復了它;選擇第三個選項中的IntelliJ菜單:

Intellij menu