ChatGPT解决这个技术问题 Extra ChatGPT

在 IntelliJ 中找不到 Maven 插件

将 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 目标 cleancompile,但配置文件/插件在 IDE 中显示为红色并带有警告。

8 年后编辑:还请在此处查看所有其他好的答案。接受的答案是一个常见的解决方案,但可能不适用于您或您的 IDE 版本

按 Ctrl + Alt + S。转到插件。是否检查了“Maven 集成”?
@memainjm 是的,它已被检查
取消选中 Maven 设置中的“脱机工作”复选框。
为什么不接受第一个答案?它似乎工作

D
Dave Jarvis

对于较新版本的 IntelliJ,请在 Maven 设置中启用使用插件注册表选项,如下所示:

单击文件🡒 设置。展开构建、执行、部署 🡒 构建工具 🡒 Maven。检查使用插件注册表。单击确定或应用。

对于 IntelliJ 14.0.1,打开首选项---不是设置---找到插件注册表选项:

单击文件🡒 首选项。

无论版本如何,也要使缓存无效:

单击文件🡒 使缓存无效/重新启动。单击无效并重新启动。

当 IntelliJ 再次启动时,问题应该会得到解决。


对于 Mac 用户,您可以在首选项下找到它。 (点击菜单栏上的IntelliJ IDEA->Preferences)或(Command⌘+,)->(同上)Build, Execution, Deployment -> Build Tools -> Maven。
使用无效和重新启动,对我有用。我正在使用 IntellIj 2020.03。
有谁知道为什么这不是 Intellij 的默认设置?这应该默认启用。
不解决问题
在 2022.1 中没有为我解决问题
J
Javaru

从 Maven 工具窗口运行强制重新导入。如果这不起作用,请使您的缓存无效(文件 > 使缓存无效)并重新启动。等待 IDEA 重新索引项目。


对于我的同事,当插件没有显示在右侧的 Maven 面板中时,强制重新导入起作用。
它对我有用。似乎它使用的是过时的 settings.xml
你如何在 IntelliJ 中进行强制重新导入?
@ap 在 Maven 工具窗口中,单击“重新加载所有 Maven 项目”按钮(它是最左边的按钮,看起来像一个圆圈中的两个箭头,很像大多数刷新图标。)它曾经被标记为“重新导入.. .”而不是“重新加载...”,因此为什么在我上面的答案中我说“重新导入”。他们改变了几年前使用的命名法。
a
anothernode

多年来,我在使用 maven-deploy 插件时遇到了这个问题,即使我没有直接在我的 POM 中包含该插件,也出现了错误。作为一种解决方法,我不得不强制将带有版本的插件包含到我的 POM 插件部分中,只是为了删除红色波浪。

在尝试了 Stack Overflow 上的所有解决方案后,我发现了问题:查看我的 .m2/repository/org/apache/maven/plugins/maven-deploy-plugin 目录有一个版本“XY”以及“2.8.2”等。所以我删除了整个 maven-deploy-plugin 目录,然后重新导入了我的 Maven 项目。

因此,问题似乎是解析存储库时的 IntelliJ 错误。不过,我不会删除整个存储库,只会删除报告错误的插件。


好的。由于 IntelliJ 与我公司的代理服务器作斗争,我有其中的一些。终于把他们炸飞了。谢谢!
之后“更新 maven 索引”(在 ctrl + enter 下)
我没有本地存储库被损坏的问题。但是添加版本就可以了。
那个目录在哪里?
找到它(Windows 10):“C:\Users\your_user\.m2\repository\org\apache\maven\plugins\maven-site-plugin\”。我在那里的另一个目录中只有一个文件。我删除了文件夹,IntelliJ 重新下载了它,但是有几个文件,包括 .jar。在此之前,我在 IntelliJ 中有 2 到 5 个错误,之后我只有 1 个。与该文件夹之前一样。
L
Logan Farci

其他答案都不适合我。对我有用的解决方案是通过 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


所以即使在我删除 \.m2\repository\ 之后,我发现我的 \.m2\repository\com\whatever\thing\my-plugin\1.2.3 只是“部分”被填充。我删除了 1.2.3目录并按照您在此处所说的进行操作,然后看起来填充正确。我认为这是“钉子”解决方案与删除 \.m2\repository 的锤子解决方案,谢谢。
我在这个线程中尝试了所有其他方法,只有这个解决了我的问题。
我认为这应该是正确的答案,可能是找不到插件的主要原因。显然,在启用关联的配置文件之前,不会下载插件依赖项(我查看了 maven 存储库和缺少红色标记的插件)。我会在删除整个 m2 存储库之前尝试此操作(重新下载可能需要一些时间)。
我尝试了许多解决方案,这是唯一对我有用的解决方案。谢谢!
这对我加载一个使用旧版本 IntelliJ 构建的项目很有用。非常感谢!
W
Wendel

带有警告的红色 maven-site-plugin 在构建站点生命周期后解决:

https://i.stack.imgur.com/HEk9s.png

我的 IntelliJ 版本是 Community 2017.2.4


这下载了我所有丢失的 Maven 插件。谢谢你的提示。
清理、编译、安装但不部署生命周期相同,为此我收到以下错误 Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
谢谢!它适用于社区 2021.3.2
R
Randhir Ray

解决了 !!!

这就是我解决问题的方式...

尝试了包括“可以通过启用“使用插件注册表”来解决它的答案之一。确实启用了,但没有运气。再次尝试线程中的答案之一,即“如果这不起作用,请使您的缓存无效(文件 > 使缓存无效)并重新启动。”这样做了,但又没有运气。尝试了这些选项..转到设置-> 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 重新导入。你猜怎么着,特别缺少的插件被下载了。我只是对其他丢失的插件遵循了类似的步骤,一切都得到了解决。


在 Windows 10 上,该目录位于:“C:\Users\your_user\.m2\repository\org\apache\maven\plugins\maven-site-plugin\”。我在那里的另一个目录中只有一个文件。我删除了文件夹,IntelliJ 重新下载了它,但是有几个文件,包括 .jar。在此之前,我在 IntelliJ 中有 2 到 5 个错误,之后我只有 1 个。与该文件夹之前一样。
第四个是一个有效的解决方案..我认为删除 repo 最终适用于任何 maven 冲突情况:)
简而言之,从内部存储库中删除违规依赖项的文件夹(.m2/repository/path/to/offending/dependency)
删除缺少插件的文件夹是唯一对我有用的解决方案。
o
olivejp

我遇到过同样的问题。我将插件添加到我的 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>

值得一提的是,我在最终放弃并直接在我的项目 pom.xml 中添加声明之前尝试了所有“上述”答案。这是一个不太理想的解决方案,因为我们必须将 maven 插件添加到每个新项目中。编辑:我更进一步,现在删除了声明。现在检查错误消失了......
帮助过我。我添加了一次存储库,将其删除,然后它运行良好。
J
Johannes

我尝试了其他答案,但没有一个为我解决了这个问题。

当我像这样明确添加 groupId 时,问题消失了:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.1.0</version>
    </plugin>
</plugins>

一旦版本号的颜色从红色变为黑色并且问题从 Problems 选项卡中消失,可以再次从有问题的插件中删除 groupId,错误不会再次出现,版本号甚至显示为version 的建议。


这正是对我有用的。然而,仍然无法解释的是,这种奇怪行为的原因是什么,尤其是考虑到 org.apache.maven.pluginsgroupIddefault value
@Marchyello 最可能的原因是 IntelliJ maven 插件中的错误。它只是希望每个插件都有一个 groupId,而对于 maven 自己的插件省略一个是完全可以的。
B
Björn Jacobs

我有同样的错误,并且能够通过删除我的旧 Maven 设置文件来摆脱它。然后我使用 mvn 命令手动更新了 Maven 插件:

mv ~/.m2/settings.xml ~/.m2/settings.xml.old
mvn -up

最后,我在 IntelliJ 的 Maven 项目选项卡中运行了“重新导入所有 Maven 项目”按钮。在我的情况下,错误消失了。


n
nils

我正在使用 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 的小红框非常好......


谢谢你的提示!完成上述操作,然后删除有问题的插件目录,然后重新导入,瞧!
这对我有用。我也做了@Vlad 给出的评论。对答案和评论都投了赞成票。格式化机器后安装的 Intellij 版本 2019.2。
非常感谢。在挣扎了 1 天后,这对我有用。
更新 cacerts 文件为我做了(使用自己的连接和自己的 SSL 证书)。 cacerts 文件的默认密码为“changeit”。 intellij-support.jetbrains.com/hc/en-us/community/posts/…。您使用以下命令导入自己的 crt 文件: keytool.exe -import -alias mynexus -keystore <文件路径>\cacerts -file <文件路径>\dataic.crt
B
Brandon Oakley

这对我有用……删除“C:\Users[Windows User Account].m2\repository”下的所有文件夹和文件。

最后在 IntelliJ 的 Maven 项目选项卡中运行“重新导入所有 Maven 项目”。


D
DependencyHell

删除本地 Maven 未知插件并重新导入所有 Maven 项目。这将解决此问题。

您可以在 View > Tool Windows > Maven 下找到它:

https://i.stack.imgur.com/CXTCx.jpg


C
CodeMonkey123

对我来说,这就像给插件一个版本一样简单:

<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>

在版本之前,您必须强制下载正确的版本。然后它完美运行。
D
Denham Coote

我最近遇到了同样的问题。其他解决方案都没有解决红色错误线。

我所做的是运行有问题的实际目标(部署、站点)。我可以看到那些依赖项然后被获取。

在那之后,重新导入就成功了。


似乎 intellij 在没有实际运行 maven 目标的情况下没有自动下载这些插件。有点道理:-)即使实际站点和部署目标确实失败了,也为我工作:-)
c
cigien

其他解决方案都不适合我。

我的解决方案:

Maven Settings -> Repositories -> 在列表中选择Local Repository,更新

像魅力一样工作!


就我而言,我还必须在同一页面中更新云 Maven 存储库索引。在我的 Mac 上,导航是:首选项 > Maven > 存储库 > 选择所需的存储库 > 单击更新 > 应用。
M
MathiasJ

我可以通过在 IntelliJ (14.1.2) 的 maven 设置中将“Maven 主目录”从“Bundled (Maven 3)”更改为“/usr/local/Cellar/maven/3.2.5/libexec”来解决这个问题。


M
Maheshkumar

取消选中 Maven 设置中的“脱机工作”复选框。


S
SureshAtt

这是我试图解决这个问题的方法,它奏效了:

手动从 .m2 存储库中删除现有插件 在 IntelliJ 中启用“使用插件注册表” 使缓存无效并重新启动 IntelliJ 在 IntelliJ 中重新导入 maven 项目

执行上述步骤后,问题已修复。希望这对您也有帮助。


N
Nipuna Saranga

对我来说,将包含插件的存储库放在 pluginRepository 标签下。例子,

<pluginRepositories>
    <pluginRepository>
        <id>pcentral</id>
        <name>pcentral</name>
        <url>https://repo1.maven.org/maven2</url>
    </pluginRepository>
</pluginRepositories>

K
Krishan

启用“使用插件注册表”并在现金无效后重新启动项目解决了我的问题

启用“使用插件注册表”>>>(intelij)文件>设置> Maven>启用maven选项列表中的选项

使现金无效 >>> 文件 > 使现金无效

而已...


为我工作。谢谢。你能解释一下它的实际作用吗?
@NIKHILCHAURASIA Maven Clean Plugin 尝试清理 Maven 在构建过程中生成的文件和目录。虽然有些插件会生成其他文件,但 Clean Plugin 假定这些文件是在目标目录中生成的。在考虑 maven-deploy-plugin 时,部署意味着不仅要复制工件,还要确保所有这些信息都正确更新。但是如果这些文件被兑现的文件覆盖,它可能会出现错误
@NIKHILCHAURASIA 执行 Maven 时,它将首先在此本地缓存中查找工件。如果在此处找不到工件,Maven 将访问远程存储库以查找工件。一旦找到,它将被存储到本地存储库中,因此可供当前和将来使用。
m
mohit jain

这对我有用

转到 Settings --> Maven --> Importing --> JDK for importer --> 使用“Use Project JDK”选项而不是之前设置的自定义 JDK。重新构建/重新导入所有依赖项。


G
Gauthier Peel

如果人工制品无法解析。进入您的 .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)可以重新加载缺少的内容。


谢谢!这终于对我有用了,所以你们可以尝试 cd ~/.m2/repository && find 。 -type f -name '*lastUpdated' | xargs rm
只有这一个帮助了我。谢谢!
A
Abhishek Gupta

这对我有用:

关闭想法

删除“*.iml”和“.idea”-目录(存在于项目的根文件夹中)

从命令行运行“mvn clean install”

将您的项目重新导入 IDEA

重新导入整个项目后,将开始安装依赖项,这将需要几分钟才能完成,具体取决于您的 Internet 连接。


D
Dmitriy Popov

我的情况:

版本 3.2.0 的 maven-javadoc-plugin 在 IntelliJ 中显示为红色。

插件存在于我的本地 maven 存储库中。

重新导入maven百万次。

从命令行运行 mvn clean install N 次。

我在 IntelliJ 中的所有 Maven 设置都是正确的。

尝试在捆绑和非捆绑 Maven 之间切换。

尝试删除整个 maven repo 并仅删除其中的插件。

以上没有任何效果。

对现代 IntelliJ IDEA 版本几乎总是有帮助的唯一一件事是“使缓存无效/重新启动”。这一次也有帮助。 maven-javadoc-plugin 不再是红色了,我可以点击它并转到插件的源 pom 文件。


R
Roman Egorov

最近我遇到了同样的问题。所有提示都不适用于我的事业。

但我修好了。

转到 Intellij IDEA 设置,找到 Maven,在其中你需要打开 Repository 选项卡并更新 maven 和本地 repos。就这样。


s
satoukum

如果您在 Maven 插件中的项目下方有红色波浪线,请尝试单击“重新导入所有 Maven 项目”按钮(看起来像一个刷新符号)。

https://i.stack.imgur.com/mIp0h.png


A
Antonio Petricca

我在 Ubuntu 18.04 上使用打包为 snap 的社区版。

每次发布 IntelliJ 时,我都会遇到这个问题。

在这种情况下,我的工作解决方案是调用无效缓存并从标记索引删除的文件菜单重新启动。


N
Noor Hossain

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>

但为什么会发生呢?什么原因,插件不应该只下载受尊重的版本吗?
通常人们不提供版本,并且可能默认版本不是现有的版本。另一个原因是 pom 中提到的错误插件版本,因此也找不到。 @Noor Hossain 提到的关键是提供正确的版本,它应该可以工作。
A
Anil

转到 IntelliJ -> 首选项 -> 插件

搜索maven,你会看到1. Maven Integration 2. Maven Integration Extension。

选择 Maven 集成选项并重新启动 Intellij


N
Nassim Hassaine

您可以将它们添加为依赖项:

<dependencies>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.4.1</version>
    </dependency>
</dependencies>

Intellij 将解决它们。成功导入依赖后,您可以清理它们。