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

Eclipse氧气运行Java9 Jigsaw应用程序

云和硕
2023-03-14

我开始学习使用java9拼图的新特性。

我按照这个教程,我管理创建一个项目与两个模块和一个外部模块依赖。(我在下面发布pom文件代码,以给出产品结构的想法)

现在我想在Eclipse Oxygen中导入我的maven项目(支持Java9插件),以便在Eclipse IDE中运行和调试该项目。

我用氧气。1a和我安装了对Oxygen4.7的Java9支持

我使用“导入现有Maven项目”并选择根pom。xml。

一切都很好,我导入了我的项目,其中两个被认为是Java项目(jsaw date cli和jigsaw date server),根模块是一个简单的m2项目。

现在,我尝试从eclipse中使用公共的Ran as Java应用程序运行jsaw date cli Main,“但我修改了:

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

如何配置项目以使cli项目自己的模块在运行时可用?我打开构建路径属性外部模块被正确导入!

我还尝试在“RunConfiguration”中设置模块

/maven-build/target/modules 

作为ModulePath条目,但结果相同。

我还尝试添加一个VM命令行参数:

--module-path  ${workspace_loc:maven-build}/target/modules/

但错误仍然存在。

我可以使用命令行运行项目

java -jar --module-path target/modules -m jigsaw.date.cli

但是我想从eclipse运行并调试它!

下面的poms.xml文件:

根pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.javacodegeeks</groupId>
        <artifactId>jigsaw-date</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>jigsaw-date-cli</artifactId>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.javacodegeeks</groupId>
                <artifactId>jigsaw-date-service</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.javacodegeeks</groupId>
            <artifactId>jigsaw-date-service</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <outputDirectory>${project.build.directory}/../../target/modules</outputDirectory>
                    <archive>
                        <manifest>
                            <mainClass>com.javacodegeeks.jigsaw.date.cli.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/../../target/modules</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

拼图cli pom。xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.javacodegeeks</groupId>
        <artifactId>jigsaw-date</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>jigsaw-date-service</artifactId>

    <properties>
        <org.apache.commons.lang.version>3.4-module</org.apache.commons.lang.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${org.apache.commons.lang.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <outputDirectory>${project.build.directory}/../../target/modules</outputDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/../../target/modules</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

拼图服务pom。xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.javacodegeeks</groupId>
        <artifactId>jigsaw-date</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>jigsaw-date-service</artifactId>

    <properties>
        <org.apache.commons.lang.version>3.4-module</org.apache.commons.lang.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${org.apache.commons.lang.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <outputDirectory>${project.build.directory}/../../target/modules</outputDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/../../target/modules</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

共有1个答案

戴嘉珍
2023-03-14

我最终使用eclipse和调试器运行了该项目,而没有删除或添加任何插件。

我只是在运行配置中添加adVM参数

--module-path  ${workspace_loc:maven-build}/target/modules/ -m jigsaw.date.cli/com.javacodegeeks.jigsaw.date.cli.Main
 类似资料:
  • 主要内容:Eclipse 运行应用程序Eclipse 运行应用程序 运行 Java 程序的最快方法是使用 Package Explorer 视图。 在包资源管理器视图中 : 右键单击包含 main 方法的 java 类。 选择“Run As”→ Java Application。 通过选择包含 main 方法的类并单击 Alt + Shift + X、J,可以使用 Package Explorer 视图执行相同的操作。 上述任一操作都

  • 代码片段- 我得到的错误: org . open QA . selenium . web Driver exception:Java . net . connect exception:无法连接到localhost/127.0.0.1:38558生成信息:版本:“3.12.0”,修订版:“7c6e0b3”,时间:“2018-05-08T15:15:03.216Z”系统信息:主机:“MPL-CJ08

  • 我已经安装了eclipse oxygen和JDK 8,但是我在下载任何插件(例如tomcat插件)时遇到了问题。如果我尝试从eclipse marketplace安装,我会遇到以下错误: HTTP服务器未知HTTP响应代码(301):HTTP://Tomcat plugin . SF . net/update/content . XML一般连接错误,响应代码=301,头(0)=HTTP/1.1 3

  • 例如。 这应该运行一个简单的hello world应用程序,摘自oracle文档。然而,当我‘运行’这个代码,没有窗口打开。取而代之的是打开一个名为“Java”的应用程序。看起来'java'只是一个位于'jdk1.8.0_25.jdk/contents/home/bin'中的'UNIX可执行文件‘。应用程序'java'绝对不显示任何东西,并且在没有强制退出的情况下无法关闭。 我在MacBook上运

  • 我喜欢使用EclipseOxygen进行java开发。我已经有大约一年没有使用这个IDE了。我记得我真的很喜欢它。然而,我记得它不是最容易安装的IDE。任何帮助都将不胜感激。 这是我安装的java。 Java 9 Java SE开发工具包9 我不知道发生了什么事。请随意推荐另一个IDE。 这里是日志文件:

  • 运行 Java 程序 我们可以在 Package Explorer 视图 可以在 Package Explorer 视图中快速运行 Java 程序。 Package Explorer 视图: 鼠标右击包含 main 函数的 java 类选择 Run As > Java Application 同样你也可以在 Package Explorer 视图中选择包含 main 方法的类并按下快捷键: Alt