gpt4 book ai didi

java - Eclipse 无法构建,但 Maven 可以,因为从 Java 8 迁移到 Java 11

转载 作者:行者123 更新时间:2023-11-30 10:06:49 25 4
gpt4 key购买 nike

这是最小的 reproduction

我正在使用 Eclipse 版本:2019-03 M1 (4.11.0 M1)Build id:20190117-2133

有问题的 jar 是 Selenium,但它们是主项目中唯一的多版本 jar,所以我认为这可能是问题的一部分

基本上,Eclipse 在构建时出错

selenium.firefox.driver cannot be resolved to a module

并且该模块下所有类的导入都给出了错误

The import org.openqa.selenium cannot be resolved

或其一些变体。有时是 org 声称无法解析

重要的是,这确实在Maven下成功编译

最佳答案

您可以将 Selenium 与 Java 11 一起使用。只需从您的 module_info.java 中删除 Selenium 并将其用作额外的 jar 文件即可。

如果您想将 Selenium 用作 Java 模块,则必须像这样编辑项目设置并将 Selenium 添加到模块路径:

Eclipse Modulepath setup

不幸的是,Maven 插件似乎在 Eclipse 项目更新期间忽略了这一点(不仅是 Selenium)。

为了解决这个问题,我还必须修改 module-info.java:

module browserAutomation{

requires org.openqa.selenium.core;
requires org.openqa.selenium.firefox;

}

这对应于 https://github.com/SeleniumHQ/selenium/tree/master/java/client/src/org/openqa/selenium 处的源代码

关于java - Eclipse 无法构建,但 Maven 可以,因为从 Java 8 迁移到 Java 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54484300/

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