gpt4 book ai didi

java - maven 没有将 test/java 类编译到目标文件夹中

转载 作者:行者123 更新时间:2023-12-01 20:05:02 28 4
gpt4 key购买 nike

我尝试通过 maven->clean 和项目->clean 清理我的项目,但它不起作用。我尝试在构建路径下显式更改输出文件夹,但不确定为 src/test/java 选择什么

我还在 pom.xml 中更新了我的 testng 插件

pom.xml

<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>abc</groupId>
<artifactId>xyz</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Test</description>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.3.1</version>
</dependency>


<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-ie-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
<version>3.3.1</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>

<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>


<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.relevantcodes/extentreports -->
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.0</version>
</dependency>


<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.1.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->

</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<build>

<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.properties</include>

</includes>
</resource>
</resources>

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

src/test/java 和 src/test/resources 的输出文件夹是/target/classes

并且我收到 TestNG class not found in classpath 错误:

org.testng.TestNGException: 
Cannot find class in classpath: testclass file

之前这段代码运行良好。我只是尝试通过更改 Maven 项目的 Artifact id 来重构项目,但从那时起就无法继续。

最佳答案

不确定这适用的范围有多大,但我在这方面取得了成功:

右键单击 > Java 构建路径 > 源代码确保为所有 4 个文件夹选中“包含:(全部)”和“排除:(无)”

src/main/java

src/main/资源

src/test/java

src/测试/资源

关于java - maven 没有将 test/java 类编译到目标文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47577386/

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