【问题标题】:Dependencies are not getting resolved in IntelliJIntelliJ 中的依赖关系没有得到解决
【发布时间】:2021-07-23 12:02:47
【问题描述】:

我已经导入了一个 Maven Java-selenium 项目,但由于某种原因,这些依赖关系没有得到解决。我使用的版本是 3.1.0 enter image description here 。 Java 版本是 1.8 。感谢任何帮助。

【问题讨论】:

  • 您的maven.resources-plugin.version 中是否定义了pom.xml
  • 嗨,是的,我已经定义了。不得不再次清理并安装 Maven。全部排序!

标签: java selenium maven intellij-idea dependencies


【解决方案1】:

首先关闭 IntelliJ - 尝试在 CMD 中工作。如果文件存在,请删除用户目录中的 settings.xml。

settings.xml 位置是 C:\Users\Nidhi\.m2 - 在 .m2 文件夹中,您可以找到 seetings.xml 文件

  1. 添加环境变量:- M2_HOME, MAVEN_HOME - 这两个的路径是你系统中的maven文件夹 在环境变量“Path”中添加路径到 Maven 的 bin 文件夹。例如:- C:\apache-maven-3.3.9\bin

  2. 打开 CMD 并 cd 到你有项目的文件夹

  3. 从这里运行 mvn clean install

【讨论】:

  • 嗨 Nidhi,在我的 .m2 文件夹中,看不到 .xml 设置。当我从 cmd 运行时,我收到以下消息: C:\Users\s122092\Desktop\Automationfolder\Code repo\settlements-creditsupport-tests> run mvn clean install 'run' is not识别为内部或外部命令,可操作程序或批处理文件。
  • 运行这个:- C:\Users\s122092\Desktop\Automationfolder\Code repo\settlements-creditsupport-tests> mvn clean
  • 我们不必写运行。让我知道你在这之后得到了什么 :) 我只是想传达我们必须运行命令“mvn clean”然后“mvn install”或者同时运行这两个命令的方式是“mvn clean install”
  • 谢谢 Nidhi,现在错误是 C:\Users\s122092\Desktop\Automationfolder\Code repo\settlements-creditsupport-tests>mvn clean 'mvn' is not known as an internal or external command,可运行的程序或批处理文件。
  • Ohhh Sharan,这意味着您的系统上没有正确安装 maven。您必须下载 maven,并在系统中设置环境变量。
【解决方案2】:

pom.xml 应如下所示:

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    ...
                    <encoding>UTF-8</encoding>
                    ...
                </configuration>
            </plugin>
        </plugins>
    ...
    </build>
</project>

或:

<project>
    <properties>
        <maven-resources-plugin.version>3.8.1</maven-resources-plugin.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven-resources-plugin.version}</version>
                <configuration>
                    ...
                    <encoding>UTF-8</encoding>
                    ...
                </configuration>
            </plugin>
        </plugins>
    ...
    </build>
</project>

编辑 pom.xml 文件后,在新构建之前清理您的项目。

【讨论】:

  • 谢谢,必须重新安装maven。它解决了所有问题。
猜你喜欢
  • 1970-01-01
  • 2016-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-22
相关资源
最近更新 更多