Java 9 auto module dependencies could not be resolved / module not found

I am trying to port some outdated applications to the new modular Java 9 system in order to strengthen its encapsulation.

I start from the outside, believing that classes on the periphery will have the least external dependencies.

As expected, I announced the start of an open module:

module com.example.user {   
    exports com.example.user;
}

This instantly crashes the entire project (inside all classes) when suddenly every import for an external dependency is no longer resolved (causing more than 1k Java problems):

Import com.otherexample cannot be allowed

Unable to allow org.springframework import

and etc.

Local packages in one project com.example.pricecontinue to work - like java.utiletc.

Maven. (Eclipse project) "Classpath", JRE "Modulepath".

? , module-info.java , pathpath ?

, , , , / , , . :

module com.foo.myapp {
  requires guava;  // guava not yet modularised, so use the filename
}

, , Eclipse, module-info.java, :

spring-core-4.3.8.RELEASE.jar

:

requires spring.core;

Java, Eclipse:

spring.core

Maven:

[ERROR] module-info.java:[39,16] error: module not found: spring.core

... .

+4
1

Robert Scholte maven-compiler-plugin 3.7.0 ( 3.6.1), ( Java 9), . requires, :

[WARNING] ********************************************************************************************************************
[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *
[WARNING] ********************************************************************************************************************
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 56 source files to ./target/classes
~~~ snip ~~~
[ERROR] module-info.java error: module not found: foo.bar

Eclipse:

foo.bar cannot be resolved to a module

, / (jar), (24) . .

POM , (target/classes). , module-info.java (, requires spring.core;), / () , .

? Maven - ( ).

- , , , Java , Maven.

+7

Source: https://habr.com/ru/post/1688179/


All Articles