将 IntelliJ 从版本 12 更新到 13 后,无法解决以下 Maven 相关插件:
org.apache.maven.plugins:maven-clean-plugin:2.4.1
org.apache.maven.plugins:maven-deploy-plugin
org.apache.maven.plugins:maven-install-plugin
org.apache.maven.plugins:maven-site-plugin
使用 IntelliJ 12 时,这些不在插件列表中。不知何故,它们在更新后被添加了,现在 IntelliJ 抱怨找不到它们。我在哪里可以从列表中删除这些插件或通过安装它们来解决问题?
我可以毫无问题地运行 maven 目标 clean
和 compile
,但配置文件/插件在 IDE 中显示为红色并带有警告。
8 年后编辑:还请在此处查看所有其他好的答案。接受的答案是一个常见的解决方案,但可能不适用于您或您的 IDE 版本
对于较新版本的 IntelliJ,请在 Maven 设置中启用使用插件注册表选项,如下所示:
单击文件🡒 设置。展开构建、执行、部署 🡒 构建工具 🡒 Maven。检查使用插件注册表。单击确定或应用。
对于 IntelliJ 14.0.1,打开首选项---不是设置---找到插件注册表选项:
单击文件🡒 首选项。
无论版本如何,也要使缓存无效:
单击文件🡒 使缓存无效/重新启动。单击无效并重新启动。
当 IntelliJ 再次启动时,问题应该会得到解决。
从 Maven 工具窗口运行强制重新导入。如果这不起作用,请使您的缓存无效(文件 > 使缓存无效)并重新启动。等待 IDEA 重新索引项目。
多年来,我在使用 maven-deploy 插件时遇到了这个问题,即使我没有直接在我的 POM 中包含该插件,也出现了错误。作为一种解决方法,我不得不强制将带有版本的插件包含到我的 POM 插件部分中,只是为了删除红色波浪。
在尝试了 Stack Overflow 上的所有解决方案后,我发现了问题:查看我的 .m2/repository/org/apache/maven/plugins/maven-deploy-plugin
目录有一个版本“XY”以及“2.8.2”等。所以我删除了整个 maven-deploy-plugin 目录,然后重新导入了我的 Maven 项目。
因此,问题似乎是解析存储库时的 IntelliJ 错误。不过,我不会删除整个存储库,只会删除报告错误的插件。
其他答案都不适合我。对我有用的解决方案是通过 cmd 手动下载丢失的工件:
mvn dependency:get -DrepoUrl=http://repo.maven.apache.org/maven2/ -Dartifact=ro.isdc.wro4j:wro4j-maven-plugin:1.8.0
在此更改之后,需要告知有关新可用工件的想法。这可以在“设置 > Maven > 存储库”中完成,在那里选择“本地”,然后单击“更新”。
编辑: -DrepoUrl 似乎已被弃用。 -DremoteRepositories 应改为使用。来源:Apache Maven Dependency Plugin – dependency:get。
带有警告的红色 maven-site-plugin 在构建站点生命周期后解决:
https://i.stack.imgur.com/HEk9s.png
我的 IntelliJ 版本是 Community 2017.2.4
Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
解决了 !!!
这就是我解决问题的方式...
尝试了包括“可以通过启用“使用插件注册表”来解决它的答案之一。确实启用了,但没有运气。再次尝试线程中的答案之一,即“如果这不起作用,请使您的缓存无效(文件 > 使缓存无效)并重新启动。”这样做了,但又没有运气。尝试了这些选项..转到设置-> Maven->导入并确保选择以下自动导入Maven项目为聚合器项目创建IDEA模块保留源...排除构建目录...使用Maven输出...生成的源文件夹:“自动检测”要...的阶段:“process-resources”自动下载:“sources”和“documentation”使用 Maven3 导入项目 VM 选项用于导入器:-Xmx512m 但再次没有成功。现在假设我有 10 个这样的插件没有得到解决,其中第一个是 'org.apache.maven.plugins:maven-site-plugin' 我去了 '.m2/repository/org/apache/maven/ plugins/' 并删除目录 'maven-site-plugin' 并再次执行 maven 重新导入。你猜怎么着,特别缺少的插件被下载了。我只是对其他丢失的插件遵循了类似的步骤,一切都得到了解决。
我遇到过同样的问题。我将插件添加到我的 pom.xml 依赖项中,它对我有用。
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<type>maven-plugin</type>
</dependency>
我尝试了其他答案,但没有一个为我解决了这个问题。
当我像这样明确添加 groupId
时,问题消失了:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
一旦版本号的颜色从红色变为黑色并且问题从 Problems
选项卡中消失,可以再次从有问题的插件中删除 groupId
,错误不会再次出现,版本号甚至显示为version
的建议。
我有同样的错误,并且能够通过删除我的旧 Maven 设置文件来摆脱它。然后我使用 mvn 命令手动更新了 Maven 插件:
mv ~/.m2/settings.xml ~/.m2/settings.xml.old
mvn -up
最后,我在 IntelliJ 的 Maven 项目选项卡中运行了“重新导入所有 Maven 项目”按钮。在我的情况下,错误消失了。
我正在使用 IntelliJ Ultimate 2018.2.6 并发现 Reimport All Maven Project 功能不使用设置中设置的 JDK:Build, Execution, Deployment |构建工具 |马文 |亚军。相反,默认情况下它在 IntelliJ_HOME/jre64/
中使用它自己的 JRE。您可以在Build, Execution, Deployment | 中为Importer 配置JDK。构建工具 |马文 |正在导入。
在我的具体问题中,JRE 密钥库中缺少 SSL 证书。不幸的是,IDEA 只将这个问题记录在它自己的日志文件中。通知 RuntimeException 的小红框非常好......
这对我有用……删除“C:\Users[Windows User Account].m2\repository”下的所有文件夹和文件。
最后在 IntelliJ 的 Maven 项目选项卡中运行“重新导入所有 Maven 项目”。
删除本地 Maven 未知插件并重新导入所有 Maven 项目。这将解决此问题。
您可以在 View > Tool Windows > Maven
下找到它:
https://i.stack.imgur.com/CXTCx.jpg
对我来说,这就像给插件一个版本一样简单:
<version>3.3.0</version>
完整的插件代码示例如下:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
我最近遇到了同样的问题。其他解决方案都没有解决红色错误线。
我所做的是运行有问题的实际目标(部署、站点)。我可以看到那些依赖项然后被获取。
在那之后,重新导入就成功了。
其他解决方案都不适合我。
我的解决方案:
Maven Settings -> Repositories -> 在列表中选择Local Repository,更新
像魅力一样工作!
我可以通过在 IntelliJ (14.1.2) 的 maven 设置中将“Maven 主目录”从“Bundled (Maven 3)”更改为“/usr/local/Cellar/maven/3.2.5/libexec”来解决这个问题。
取消选中 Maven 设置中的“脱机工作”复选框。
这是我试图解决这个问题的方法,它奏效了:
手动从 .m2 存储库中删除现有插件 在 IntelliJ 中启用“使用插件注册表” 使缓存无效并重新启动 IntelliJ 在 IntelliJ 中重新导入 maven 项目
执行上述步骤后,问题已修复。希望这对您也有帮助。
对我来说,将包含插件的存储库放在 pluginRepository 标签下。例子,
<pluginRepositories>
<pluginRepository>
<id>pcentral</id>
<name>pcentral</name>
<url>https://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
启用“使用插件注册表”并在现金无效后重新启动项目解决了我的问题
启用“使用插件注册表”>>>(intelij)文件>设置> Maven>启用maven选项列表中的选项
使现金无效 >>> 文件 > 使现金无效
而已...
这对我有用
转到 Settings --> Maven --> Importing --> JDK for importer --> 使用“Use Project JDK”选项而不是之前设置的自定义 JDK。重新构建/重新导入所有依赖项。
如果人工制品无法解析。进入您的 .m2/repository 目录并检查您是否没有那种文件:
build-helper-maven-plugin-1.10.pom.lastUpdated
如果文件夹中没有任何人工制品,只需将其删除,然后再次尝试在 IntelliJ 中重新导入。
这些文件的内容如下:
#NOTE: This is an Another internal implementation file, its format can be changed without prior notice.
#Fri Mar 10 10:36:12 CET 2017
@default-central-https\://repo.maven.apache.org/maven2/.lastUpdated=1489138572430
https\://repo.maven.apache.org/maven2/.error=Could not transfer artifact org.codehaus.mojo\:build-helper-maven-plugin\:pom\:1.10 from/to central (https\://repo.maven.apache.org/maven2)\: connect timed out
如果没有 *.lastUpdated 文件,IntelliJ(或者顺便说一下 Eclipse)可以重新加载缺少的内容。
这对我有用:
关闭想法
删除“*.iml”和“.idea”-目录(存在于项目的根文件夹中)
从命令行运行“mvn clean install”
将您的项目重新导入 IDEA
重新导入整个项目后,将开始安装依赖项,这将需要几分钟才能完成,具体取决于您的 Internet 连接。
我的情况:
版本 3.2.0 的 maven-javadoc-plugin 在 IntelliJ 中显示为红色。
插件存在于我的本地 maven 存储库中。
重新导入maven百万次。
从命令行运行 mvn clean install N 次。
我在 IntelliJ 中的所有 Maven 设置都是正确的。
尝试在捆绑和非捆绑 Maven 之间切换。
尝试删除整个 maven repo 并仅删除其中的插件。
以上没有任何效果。
对现代 IntelliJ IDEA 版本几乎总是有帮助的唯一一件事是“使缓存无效/重新启动”。这一次也有帮助。 maven-javadoc-plugin 不再是红色了,我可以点击它并转到插件的源 pom 文件。
最近我遇到了同样的问题。所有提示都不适用于我的事业。
但我修好了。
转到 Intellij IDEA 设置,找到 Maven,在其中你需要打开 Repository 选项卡并更新 maven 和本地 repos。就这样。
如果您在 Maven 插件中的项目下方有红色波浪线,请尝试单击“重新导入所有 Maven 项目”按钮(看起来像一个刷新符号)。
https://i.stack.imgur.com/mIp0h.png
我在 Ubuntu 18.04 上使用打包为 snap 的社区版。
每次发布 IntelliJ 时,我都会遇到这个问题。
在这种情况下,我的工作解决方案是调用无效缓存并从标记索引删除的文件菜单重新启动。
2021 年 6 月:
不删除,不重新导入。
我所做的是,我打算:
C:\Users\dell\.m2\repository\org\apache\maven\plugins
然后双击每个插件文件夹,查看下载的版本。
然后我回到pom文件,根据下载的版本,我在<version>....</version>
标签中仔细更改了那些版本。然后刷新。
这样一来,所有红色标记都消失了,甚至那些黄色标记也消失了。
都干净。阿罕杜里拉。
这是我的完整 pom 文件,供进一步通知。该项目是带有 Shade 的 JavaFx+Maven:
<?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>main.java.sample</groupId>
<artifactId>ThreeColumnTable</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>resources</goal>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/generated-groovy-stubs</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>org.example.App</mainClass>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<mainClass>org.example.App</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>project-classifier</shadedClassifierName>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.example.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
转到 IntelliJ -> 首选项 -> 插件
搜索maven,你会看到1. Maven Integration 2. Maven Integration Extension。
选择 Maven 集成选项并重新启动 Intellij
您可以将它们添加为依赖项:
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
</dependency>
</dependencies>
Intellij 将解决它们。成功导入依赖后,您可以清理它们。