【问题标题】:IntelliJ can't find Maven dependencies at runtimeIntelliJ 在运行时找不到 Maven 依赖项
【发布时间】:2018-07-13 22:46:56
【问题描述】:

我没有看到任何红线,但是当我运行 (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 构建运行良好,依赖项列在外部库下。

【问题讨论】:

  • 你能检查一下你是否可以从命令行运行应用程序吗?
  • 尝试在设置(首选项)| 中启用运行前不要在IDEA中编译项目语言和框架 | Play2 设置或在此处启用 Play2 编译器。

标签: java maven intellij-idea pom.xml


【解决方案1】:

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

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

【讨论】:

  • 我不必每次都这样做:只需在 Maven.Import 设置中启用 自动导入 Maven 项目 选项。
  • 谢谢!我不知道。
【解决方案2】:

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

当 Maven 依赖项使用分类器时,IDEA 在构建其类路径时会忽略分类器并尝试为该依赖项使用未分类的工件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-01
    • 2020-04-18
    相关资源
    最近更新 更多