gpt4 book ai didi

java - 在 IntelliJ 中找不到 TestNG

转载 作者:行者123 更新时间:2023-12-01 08:57:55 25 4
gpt4 key购买 nike

我有一个Ubuntu Studio 16.10 。我有一个IntelliJ IDEA 2016.3.2内部版本 #IC-163.10154.41,构建于 2016 年 12 月 21 日

JRE: 1.8.0_112-release-408-b6 amd64

JVM: OpenJDK 64-Bit服务器 VM 由 JetBrains s.r.o 提供我用Apache Maven 3.3.9我在我的 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>
<repositories>
<repository>
<id>jcenter</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<groupId>test</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceencoding>UTF-8</project.build.sourceencoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>

<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

</plugins>


</build>


</project>

我转到我的项目目录并运行 mvn clean install我还检查了另一篇文章,其中建议右键单击项目文件夹并选择 Maven-> 重新导入,但该选项不可用。我有一个BUILD Success 。尽管外部库显示 junit 的存在。我从来没有见过 TestNG。在日志中它说..下载testng-6.9.12.jar当我使用locate testng-6.9.12.jar时我所得到的只是返回到命令提示符。在编辑器中,我尝试导入 org.testng.*;我一写完导入语句就被删除了。我在 Intellij 上使用了 vim 的安排。 Ubuntu 16.10我也尝试过从 jcentral 和 maven 存储库下载,但没有成功。

我只能在外部库中看到 TestNG junitJava 1.8

最佳答案

可能是因为Maven找不到6.9.12在 Maven 中心(由于你的 pom 文件没有任何 <repository> 标签,maven 将尝试仅在 repo1.maven.org/maven2/ 中寻找你的 Artifact )。

我尝试搜索它here并且找不到版本 6.9.12

TestNG最新发布的版本是6.10 。所以请更换您的 <version>标签在你的 <dependency>6.10然后再试一次。应该可以解决这个问题。

<scope>test</scope>只是告诉 Maven 的一种便捷方式,仅当您运行测试时才需要解析 TestNG。默认范围compile告诉 TestNG 在编译代码本身时将提供一个 Artifact (通常为 src/main/java )。它与您在这里面临的问题没有任何关系(至少据我所知)

关于java - 在 IntelliJ 中找不到 TestNG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41921992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com