我对Maven并不熟悉,不太确定它的用途,但我认为它是用于导入外部库,以便在编码时可用。我已经导入了依赖项,并且没有出现错误,如下所示:

但是在输入导入时,所有的内容都是红色的,就好像找不到一样。什么都找不到。

如果我粘贴整个导入行,就会自动删除。
这不是Maven应该做的吗?还是在它开始工作之前还有其他的事情要做呢?我还将其设置为自动导入Maven项目。
编辑:为了清晰起见,它当然在我的pom.xml文件中,否则它不会出现在上面截图中的外部库中:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>uk.co.caprica</groupId>
<artifactId>vlcj</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>uk.co.caprica</groupId>
<artifactId>vlcj-javafx</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>附加编辑:一些屏幕截图显示,直接输入类没有更好的效果。Intellij只是找不到任何东西:


发布于 2020-12-04 11:33:53
这种特定的依赖似乎是按照模块化的。因此,我们需要requires在module-info.java文件中。
module com.sample {
requires javafx.controls;
exports com.sample;
requires transitive javafx.graphics;
requires uk.co.caprica.vlcj;
requires uk.co.caprica.vlcj.javafx;
}在此之后,依赖项在代码中突然可见并完全可用。
https://stackoverflow.com/questions/65092978
复制相似问题