idea: too many module declarations found

不羁的心 提交于 2019-12-30 18:07:06

问题


I want to create hello world java 9 application and start it in intellij idea.

Now I have following structure:

content of inner module-info.java:

module my.module.Second {
    requires my.module.First;
}

content of outer module-info.java:

module my.module.First {
    exports my.pack;
}

But idea complains about my project:

Error:(1, 1) java: too many module declarations found

I don't understand why it happens and what really wrong. So

Question:

My question is how to force idea to accept my hello world.

P.S. From the first glance error looks obvious but I have project which I downloaded from github with the same structure but it works properly and idea doesn't complain about it:


回答1:


According to Oracle Jar file specification

A modular JAR file is a JAR file that has a module descriptor, module-info.class, in the top-level directory (or root) directory.

One Jar could contain only one module.

To fix you problem you have to split your project (create several maven modules)



来源:https://stackoverflow.com/questions/56293275/idea-too-many-module-declarations-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!