当前位置: 首页 > 知识库问答 >
问题:

模块没有找到,即使它存在[重复]

长孙逸仙
2023-03-14

我在运行Java应用程序时遇到了一个小问题(当我通过Maven运行它时,它工作得很好)。我得到一个错误:

Error occurred during initialization of boot layer
java.lang.module.FindException: Module moduleName not found

模块位于mysrc文件夹中,我的文件夹结构如下:

对于module-info.java-

对于我的类src/main/java/frogger/game/main菜单。java

奇怪的是,当我在模块信息中写出模块名称时。java文件它再次开始工作,但在几次运行后中断。

编辑:

module info位置更改为src/main/java修复了该问题,但是,它破坏了我的Maven install命令并引发以下错误:

Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile failed.: IllegalArgumentException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project projectName: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init> (Unknown Source)
    at org.objectweb.asm.ClassReader.<init> (Unknown Source)
    at org.objectweb.asm.ClassReader.<init> (Unknown Source)
    at org.codehaus.plexus.languages.java.jpms.AsmModuleInfoParser.parse (AsmModuleInfoParser.java:80)
    at org.codehaus.plexus.languages.java.jpms.AsmModuleInfoParser.getModuleDescriptor (AsmModuleInfoParser.java:65)
    at org.codehaus.plexus.languages.java.jpms.LocationManager.resolvePaths (LocationManager.java:113)
    at org.apache.maven.plugin.compiler.CompilerMojo.preparePaths (CompilerMojo.java:219)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:762)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:168)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

共有1个答案

彭俊智
2023-03-14

>

  • 一种方法是创建新项目,然后要求您写项目的名称。之后,您被要求创建module-info.java。您必须选择不创建选项。之后,创建与原始项目相同的项目。

    另一种方法是转到运行配置,将类位置添加到vm参数,并将模块名称/路径添加到main。进一步解释

  •  类似资料:
    • 我正在使用 PyCharm 并且在导入模块时遇到问题,当我尝试运行应用程序并对所有导入都获得“找不到模块”时,我设置了一个 venv 并通过 pip install -r 导入了依赖项。如果我在 PyCharm 中打开一个终端并执行 pip 列表,则会列出所有必需的模块 此外,PyCharm 可以归档模块 - 我可以在键入模块名称时执行完成。我还能尝试什么?

    • 这是我用来使用铬Web驱动程序和python查找元素的代码行 这是每次尝试运行代码时抛出的错误 这些是标题栏上的按钮,我试图让我的代码单击html按钮 这是努力按钮的html代码,我试图使用selenium来定位它,以便它可以点击这里,但它总是说没有找到这样的元素 我甚至创建了一个单独的函数来一次又一次地找到元素并在每次成功尝试后Hibernate5秒,直到它点击了元素,但仍然没有运气它永远运行而

    • 控制台中出现以下错误: 我的文件夹文件: 那么,虽然存在,但为什么我会出现错误呢?

    • 下面是网站地图。php,并且它被认为是一个XML网站地图(为了SEO)。它背后的原理是:它拉取并将其正确格式化为XML站点地图链接。 它似乎运行良好,请现场查看:http://loaistudio.com/sitemap然而,我并不确定它是否被识别为XML文件——所以我对它进行了测试,但测试失败了——没有找到站点地图。。。看看这里:http://seositecheckup.com/test_ch

    • 问题内容: 我有一个很难理解为什么我得到确保后httplib2都 被 安装。见下文: 我也做过 水暖!>在天堂摇动拳头< 问题答案: 将此添加到.bash_profile 然后得到: 无法肯定地说为什么安装而不是系统默认版本,但是现在它们相同,因此现在可以正常使用。

    • 所以我用这个mock(potatoConsumer)订阅,rxJava调用了“accept”,mockito将其标记为交互,但mockito认为这个交互不是我所期望的,为什么? 图书馆的版本使用了她: 一些由powermock模拟的字段在“验证”时失败,但由mockito模拟的字段不是 Mockito不能模拟未打开的字段,没有,但Mockito与Powermock maker inline冲突 P