gpt4 book ai didi

java - 在maven中编译问题

转载 作者:行者123 更新时间:2023-11-30 01:59:07 25 4
gpt4 key购买 nike

当我使用命令-mvn install时,我遇到了这样的问题。问题是

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:testCompile (default-testCompile) on project Demo: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

我在我的工作区中运行我的程序,默认情况下仅 jre1.8,但对于之前的程序,它运行成功。仅此一点我就面临问题!

我的POM文件

<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>Demo</groupId>
<artifactId>Demo</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>
</properties>

<dependencies>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>

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

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>

<configuration>

<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>

</configuration>

</plugin>
</plugins>
</build>
</project>

Compiler issue

请帮我解决这个问题!

最佳答案

尝试设置环境变量JAVA_HOME指向jdk。 https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/

此外,尝试将 Maven 编译器插件设置为您正在使用的编译器版本。

https://maven.apache.org/plugins/maven-compiler-plugin/usage.html

关于java - 在maven中编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53465722/

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