java - 在 Maven 中编译问题
问题描述
当我使用命令时,我-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>
请帮我解决这个问题!
解决方案
尝试设置环境变量 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
推荐阅读
- angular - Karma-Test:在其他测试中使用异步时随机测试失败
- outlook-addin - Outlook OWA 插件功能区图标文本
- c# - Selenium SelectBySubText 与忽略大小写 C#
- spring - 验证码实现
- django-tables2 - 如何将 LazyPaginator 与 RequestConfig 和 Table 类一起使用?
- c# - 如何将图像从 SQL 放到 c# 中的页面
- java - 为什么在这段代码中使用布尔变量?
- javascript - 当我使用 lit-html 表达式时,`this` 会丢失
- c# - 带单引号和不带单引号的 DataTable 选择条件
- python - 使用 Python 将 Twitter 数据直接发送到 Google Cloud 数据存储