java创建出现module,如何使Eclipse停止要求在新的Java项目创建时创建module-info Java文件?...

Everytime I try to create a new java project Eclipse keeps asking if I want to add a module-info java file to the source folder. It's getting pretty annoying as there's no immediately obvious option to opt out of this check.

IDE for Java Developers, Photon release 4.8.0

解决方案

See while creating a new project, after you click>> next on the very first dialog "new java project." There is one another dialog box pops up when you click >> finish. It will lead you to the 3rd dialog box which asks for the creation of module-info java file?? & gives you two option create & don't create.

You should select "don't create."

Here are some advantages of the file

module-info.java contents:

To declare a jar file as a named module, one needs to provide a module-info.class file, which is, naturally, compiled from a module-info.java file. It declares the dependencies within the module system and allows the compiler and the runtime to police the boundaries/access violations between the modules in your application. Let’s look at the file syntax and the keywords you can use.

Module module.name – declares a module called module.name.

Requires module.name – specifies that our module depends on the module module.name, allows this module to access public types exported in the target module.

Requires transitive module.name – any modules that depend on this module automatically depend on module.name.

Exports pkg.name says that our module exports public members in package pkg.name for every module requiring this one.

Exports pkg.name to module.name the same as above, but limits which modules can use the public members from the package pkg.name.

Uses class.name makes the current module a consumer for service class.name.

Provides class.name with class.name.impl registers class.name.impl class a service that provides an implementation of the class.name service.

opens pkg.name allows other modules to use reflection to access the private members of package pkg.name.

Opens pkg.name to module.name does the same, but limits which modules can have reflection access to the private members in the pkg.name.

One great thing about the module-info.java syntax is that the modern IDEs would fully support your efforts of writing them. Perhaps all of them would work beautifully. I know that IntelliJ IDEA does content assist, quick fixes of the module files when you import classes from the module you haven’t required yet, and so on. I don’t doubt Eclipse IDE and NetBeans IDE offer the same.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值