Eclipse - 添加 module-info.java 时找不到模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47511379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse - module not found when adding module-info.java
提问by Gert Kommer
I have a simple hello world project in eclipse that I want to run with java 9. The program runs when I don't have a module-info.java
file but when I add that file I get the following error:
我在 eclipse 中有一个简单的 hello world 项目,我想用 java 9 运行它。当我没有module-info.java
文件时程序运行,但是当我添加该文件时,我收到以下错误:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module modulefinder not found
Steps to reproduce
1. Create a new maven project
2. Change compiler and build path jre to 9
3. Auto generate module-info.java
4. Update junit dependency in junit to 4.12 if eclipse complains
5. Run the project
复现步骤
1.新建maven工程
2.将编译器和构建路径jre改为9
3.自动生成module-info.java
4.如果eclipse报错,将junit中的junit依赖更新为4.12
5.运行项目
Is this an eclipse related issue or am I missing something when running the project?
这是与日食相关的问题还是我在运行项目时遗漏了什么?
FYI eclipse version I use is Oxygen.1a Release (4.7.1a)
仅供参考,我使用的 eclipse 版本是 Oxygen.1a Release (4.7.1a)
采纳答案by Gert Kommer
Found the answer based on intellij output:) I had to add the location of the classes to the vm arguments in the run configurations as well as the module name/path to main. like below. See the java -help
command for more info regarding -m
and -p
根据 intellij 输出找到答案:) 我必须将类的位置添加到运行配置中的 vm 参数以及模块名称/主路径。像下面。java -help
有关-m
和的更多信息,请参阅命令-p