【问题标题】:Intellij - Package 'javax.smartcardio' is declared in module 'java.smartcardio', which is not in the module graph but the project compiles fineIntellij - 包'javax.smartcardio'在模块'java.smartcardio'中声明,它不在模块图中,但项目编译良好
【发布时间】:2021-12-29 06:49:13
【问题描述】:

我正在将一个小型 Spring Boot 应用程序从 Java 8 升级到 Java 11。这个项目使用包 javax.smartcardio。我正在用 maven 构建它。

pom.xml 基本上包含以下依赖项/插件:

  • spring-boot-starter-parent (2.5.6)
  • spring-boot-starter-test
  • spring-boot-starter-web
  • spring-boot-autoconfigure
  • pebble-spring-boot-2-starter
  • spring-boot-starter-security
  • spring-boot-maven-plugin
  • maven 资源插件
  • maven 组装插件
  • exec-maven-plugin

升级我的所有依赖项并使用 OpenJDK11 后,项目编译并运行良好 (mvn clean package)。尤其是使用 javax.smartcardio 中的类的部分也可以正常工作。

然而,Intellij 以红色突出显示我对包 javax.smartcardio. 的所有导入。当悬停在它上面时,它告诉我Intellij - Package 'javax.smartcardio' is declared in module 'java.smartcardio', which is not in the module graph。 Intellij 建议通过 --add-modules java.smartcardio 的编译器选项添加此模块。这样做时,Intellij 停止突出显示导入。

我现在的问题是,为什么 Intellij 会突出显示这些导入,尽管一切都在编译和运行良好?我错过了什么?编译时添加该模块是否重要?也许maven已经为我做了这方面的事情?如果是这样,我应该注意哪一部分?

我已经阅读了有关使用 module-info.java 的信息,但得出的结论是,使用它来解决我的问题并不是最好的解决方案。另见Any plans for Java 9 Jigsaw (module) of Spring projects?

【问题讨论】:

    标签: maven intellij-idea java-11


    【解决方案1】:

    这是一个已知问题,请投票给IDEA-259485 非标准模块不是非模块化模块中类路径的一部分。

    【讨论】:

      猜你喜欢
      • 2018-02-15
      • 1970-01-01
      • 1970-01-01
      • 2012-09-29
      • 1970-01-01
      • 2012-12-14
      • 1970-01-01
      • 2019-11-07
      • 1970-01-01
      相关资源
      最近更新 更多