想法:发现太多模块声明 [英] idea: too many module declarations found

查看:269
本文介绍了想法:发现太多模块声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个hello world java 9应用程序,并以intellij idea启动它.

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

现在我具有以下结构:

Now I have following structure:

内部module-info.java的内容:

content of inner module-info.java:

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

外部module-info.java的内容:

content of outer module-info.java:

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

但是Idea抱怨我的项目:

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

我的问题是如何强迫思想接受我的世界.

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

PS 乍一看,错误似乎很明显,但是我有一个从github下载的具有相同结构的项目,但是它可以正常工作,并且想法没有抱怨:

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:

推荐答案

根据 Oracle Jar文件规范

模块化JAR文件是具有模块描述符的JAR文件, module-info.class,位于顶级目录(或根目录)中.

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

一个Jar只能包含一个模块.

One Jar could contain only one module.

要解决您的问题,您必须拆分项目(创建几个Maven模块)

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

这篇关于想法:发现太多模块声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆