IntelliJ无法在运行时找到Maven依赖项

时间:2018-02-03 16:32:01

标签: java maven intellij-idea pom.xml

我没有得到任何红线,但是当我运行(Play)应用程序时,IntelliJ无法找到我的Maven依赖项。试过invalidate cache/restart。尝试运行mvn clean install

编译器错误消息

(compile:compileIncremental) Compilation failed
[info] Compiling 8 Scala sources and 5 Java sources to /Users/****/IdeaProjects/GeoMood/target/scala-2.11/classes...
[error] /Users/****/IdeaProjects/GeoMood/app/views/show_tweets.scala.html:1: not found: value twitter4j
[error] @import twitter4j.Status

的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>geomood</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>edu.stanford.nlp</groupId>
            <artifactId>stanford-corenlp</artifactId>
            <version>3.8.0</version>
        </dependency>
        <dependency>
            <groupId>edu.stanford.nlp</groupId>
            <artifactId>stanford-corenlp</artifactId>
            <version>3.8.0</version>
            <classifier>models</classifier>
        </dependency>

        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-core</artifactId>
            <version>[4.0,)</version>
        </dependency>
    </dependencies>
</project>

有没有人有任何想法为什么IntelliJ没有选择这个? maven构建运行正常,依赖项列在外部库下。

2 个答案:

答案 0 :(得分:0)

我通常必须执行以下操作以使IntelliJ知道pom.xml中对依赖项的更改:

  1. 在IntelliJ的项目视图中右键单击项目的根文件夹
  2. 转到Maven菜单项,然后打开Maven子菜单
  3. 点击重新导入 Maven popup menu

答案 1 :(得分:0)

听起来你已经遇到了错误IDEA-148573

  

当Maven依赖项使用分类器时,IDEA在构建其类路径时忽略分类器并尝试将非分类工件用于该依赖项