Java 10 Eclipse Maven项目报错:java.lang.module.FindException: Module myproject not found
Hey there, let's walk through the most common reasons you're seeing that Error occurred during initialization of boot layer java.lang.module.FindException: Module myproject not found error, and how to fix them:
Check your Eclipse run configuration's module path
When you set up your run configuration, Eclipse might not have automatically added your project's compiled module to the module path. Head to Run Configurations > Java Application > [Your Run Config] > Arguments tab. Look at the VM arguments—make sure there's a--module-pathentry that includes your project'starget/classesdirectory (where the compiledmodule-info.classlives). If it's missing, add it manually, or ensure the "Use module path" option is enabled if available.Verify
module-info.javaplacement and Maven Java version- Your
module-info.javamust live directly insrc/main/java(not inside a subpackage) for the JVM to recognize it as the module descriptor. Double-check its location—if it's nested in a package, move it up to the root of your source directory. - Make sure your
pom.xmlis configured for Java 10, since older compiler versions won't properly handle module syntax. Add or update these properties:<properties> <maven.compiler.source>10</maven.compiler.source> <maven.compiler.target>10</maven.compiler.target> </properties>
- Your
Sync Eclipse with Maven and rebuild
Eclipse and Maven can sometimes get out of sync, leading to stale compiled files. Try these steps:- Right-click your project > Maven > Update Project (check "Force Update of Snapshots/Releases" to refresh dependencies fully).
- Go to Project > Clean and select "Clean all projects".
- Rebuild with Project > Build All.
Confirm module name consistency
Ensure the module name inmodule-info.java(myproject) matches what Eclipse recognizes. Right-click your project > Properties > Java Build Path > Module tab—check that the module name listed here is exactlymyproject. Mismatched names will prevent the JVM from locating your module.Validate your dependencies are properly resolved
Even though the error is about your own module, missing or broken dependencies can sometimes throw off module resolution. Check that all therequiresmodules in yourmodule-info.javaare present in Eclipse's Maven Dependencies library. If any are missing, run Maven > Download Sources and Javadoc to pull them into your local repo, then re-sync the project.
内容的提问来源于stack exchange,提问作者Arya

