4

我正在尝试将旧的 java 项目迁移到 java 9,并且最好尝试新的 module-info.java 功能。该项目使用 maven 依赖项,据我所知,那些将 .jar 迁移为未命名的模块。项目本身在替换了一些折旧的库后运行良好,但是当我尝试添加 module-info.java 文件时出现问题。它不再能够与任何 Maven 导入交互。我对未命名模块的理解是错误的吗?我认为它们能够与同一个项目中的命名/自动模块共存。如果不是,为什么在创建 module-info.java 后我无法从我的 Maven 依赖项中导入类?

4

1 回答 1

0

This is because all legacy jars will not be unnamed modules but it will be "automatic" modules. Learnt it the hard way. I had a gson-2.8.5.jar in my classpath and my classes in a module cannot import those classes. I had to move the jar to module-path and then specify "requires gson;" in the module-info.java of my module to get this working.

于 2019-01-24T17:27:44.250 回答