module-info – 模块未找到: com.fasterxml.jackson.core

huangapple go评论102阅读模式
英文:

module-info - module not found: com.fasterxml.jackson.core

问题

I am trying to create a module-info file for my application but getting some issues with the com.fasterxml.jackson.core module when trying to build the application:

  1. ...\src\main\java\module-info.java:5: error: module not found: com.fasterxml.jackson.core
  2. requires com.fasterxml.jackson.core;

module-info:

  1. module foo {
  2. requires org.slf4j;
  3. requires org.apache.commons.lang3;
  4. requires com.fasterxml.jackson.annotation;
  5. requires com.fasterxml.jackson.core;
  6. requires com.fasterxml.jackson.databind;
  7. }

build.gradle:

  1. ...
  2. dependencies {
  3. implementation 'org.slf4j:jcl-over-slf4j:2.0.7'
  4. implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.1'
  5. implementation 'com.fasterxml.jackson.core:jackson-core:2.15.1'
  6. implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'
  7. implementation 'com.google.guava:guava:31.1-jre'
  8. // Logging
  9. implementation 'org.slf4j:slf4j-api:2.0.7'
  10. implementation 'org.apache.commons:commons-lang3:3.12.0'
  11. implementation 'commons-codec:commons-codec:1.15'
  12. // http tools
  13. api 'org.yamj:api-common:2.1'
  14. // testing
  15. testImplementation 'junit:junit:4.13.2'
  16. testImplementation 'org.mockito:mockito-core:5.3.1'
  17. }
  18. tasks.withType(JavaCompile).configureEach {
  19. options.encoding = 'UTF-8'
  20. }
  21. java {
  22. withJavadocJar()
  23. withSourcesJar()
  24. }
  25. ...

I'm using JDK 17 (Amazon Corretto) & Gradle 8.1.1

Does anyone know why this is happening and how to fix it? I've tried different versions of the jackson dependencies and still get the same issue.

If I remove

  1. requires com.fasterxml.jackson.core;
  2. requires com.fasterxml.jackson.databind;

from the module-info.java, it will try to build but get errors about visibility:

  1. ...\src\main\java\foo\app.java:4: error: package com.fasterxml.jackson.databind is not visible
  2. import com.fasterxml.jackson.databind.DeserializationFeature;
  3. ^
  4. (package com.fasterxml.jackson.databind is declared in module com.fasterxml.jackson.databind, but module foo does not read it)
英文:

I am trying to create a module-info file for my application but getting some issues with the com.fasterxml.jackson.core module when trying to build the application:

  1. ...\src\main\java\module-info.java:5: error: module not found: com.fasterxml.jackson.core
  2. requires com.fasterxml.jackson.core;

module-info:

  1. module foo {
  2. requires org.slf4j;
  3. requires org.apache.commons.lang3;
  4. requires com.fasterxml.jackson.annotation;
  5. requires com.fasterxml.jackson.core;
  6. requires com.fasterxml.jackson.databind;
  7. }

build.gradle:

  1. ...
  2. dependencies {
  3. implementation 'org.slf4j:jcl-over-slf4j:2.0.7'
  4. implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.1'
  5. implementation 'com.fasterxml.jackson.core:jackson-core:2.15.1'
  6. implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'
  7. implementation 'com.google.guava:guava:31.1-jre'
  8. // Logging
  9. implementation 'org.slf4j:slf4j-api:2.0.7'
  10. implementation 'org.apache.commons:commons-lang3:3.12.0'
  11. implementation 'commons-codec:commons-codec:1.15'
  12. // http tools
  13. api 'org.yamj:api-common:2.1'
  14. // testing
  15. testImplementation 'junit:junit:4.13.2'
  16. testImplementation 'org.mockito:mockito-core:5.3.1'
  17. }
  18. tasks.withType(JavaCompile).configureEach {
  19. options.encoding = 'UTF-8'
  20. }
  21. java {
  22. withJavadocJar()
  23. withSourcesJar()
  24. }
  25. ...

I'm using JDK 17 (Amazon Corretto) & Gradle 8.1.1

Does anyone know why this is happening and how to fix it? I've tried different versions of the jackson dependencies and still get the same issue.

If I remove

  1. requires com.fasterxml.jackson.core;
  2. requires com.fasterxml.jackson.databind;

from the module-info.java, it will try to build but get errors about visibility:

  1. ...\src\main\java\foo\app.java:4: error: package com.fasterxml.jackson.databind is not visible
  2. import com.fasterxml.jackson.databind.DeserializationFeature;
  3. ^
  4. (package com.fasterxml.jackson.databind is declared in module com.fasterxml.jackson.databind, but module foo does not read it)

答案1

得分: 1

这是2.15.1版本中的一个额外模块信息文件1。这将在下一个版本2.15.2中修复。感谢@VGR指出,使用版本2.15.0将解决此问题,直到下一个版本发布为止。

英文:

There was an Extra module-info.class in 2.15.1. This will be fixed in the next release: 2.15.2. Thanks to @VGR for pointing out that using version 2.15.0 will fix this issue, until the next version has been released.

huangapple
  • 本文由 发表于 2023年5月18日 07:48:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76276873.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定