2015-10-27 189 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