如何使用Maven classpath来运行Java主类? [英] How to use Maven classpath to run Java main class?

查看:161
本文介绍了如何使用Maven classpath来运行Java主类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Maven构建我的Rhino JavaScript项目,下载相关库,并在运行时管理类路径。我可以通过以下方式使用Maven exec插件运行JavaScript入口点:

I'm currently using Maven to build my Rhino JavaScript project, download dependent libraries, and manage the classpath at runtime. I'm able to run the JavaScript entry point by using the Maven exec plugin, in the following way:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>java</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>org.mozilla.javascript.tools.shell.Main</mainClass>
                <classpathScope>runtime</classpathScope>
                <arguments>
                    <argument>path/to/entryPoint.js</argument>
                </arguments>
            </configuration>
        </plugin>

这很有效,但问题是maven大约需要10秒才能启动,这是关于比我的程序运行时间长10倍。有没有办法:

This works well, but the problem is that maven takes about 10 seconds just to start, which is about 10 times longer than it takes my program to run. Is there a way to either:


  1. 提高maven exec插件的性能,以便花费更少的时间来启动,或者

  2. 导出maven在运行时使用的类路径,以便我可以从脚本启动我的程序?


推荐答案


  1. 您可以使用 -o / - -offline 切换告诉Maven不要检查快照或插件更新。

  1. You can use the -o / --offline switch to tell Maven to not bother checking for snapshot or plugin updates.

使用 appassembler 程序集 插件生成启动脚本(将自动生成)在appassembler的情况下)引用所需的类路径。

Use the appassembler or assembly plugins to generate startup scripts which will automatically (in the case of appassembler) reference the desired classpath.

这篇关于如何使用Maven classpath来运行Java主类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆