<i id='fEZ0s'><tr id='fEZ0s'><dt id='fEZ0s'><q id='fEZ0s'><span id='fEZ0s'><b id='fEZ0s'><form id='fEZ0s'><ins id='fEZ0s'></ins><ul id='fEZ0s'></ul><sub id='fEZ0s'></sub></form><legend id='fEZ0s'></legend><bdo id='fEZ0s'><pre id='fEZ0s'><center id='fEZ0s'></center></pre></bdo></b><th id='fEZ0s'></th></span></q></dt></tr></i><div id='fEZ0s'><tfoot id='fEZ0s'></tfoot><dl id='fEZ0s'><fieldset id='fEZ0s'></fieldset></dl></div>
      • <bdo id='fEZ0s'></bdo><ul id='fEZ0s'></ul>
      <tfoot id='fEZ0s'></tfoot>

    1. <legend id='fEZ0s'><style id='fEZ0s'><dir id='fEZ0s'><q id='fEZ0s'></q></dir></style></legend>
    2. <small id='fEZ0s'></small><noframes id='fEZ0s'>

      使用 Maven 的环境变量

      Environment Variable with Maven(使用 Maven 的环境变量)

        <legend id='JTghY'><style id='JTghY'><dir id='JTghY'><q id='JTghY'></q></dir></style></legend>
          <i id='JTghY'><tr id='JTghY'><dt id='JTghY'><q id='JTghY'><span id='JTghY'><b id='JTghY'><form id='JTghY'><ins id='JTghY'></ins><ul id='JTghY'></ul><sub id='JTghY'></sub></form><legend id='JTghY'></legend><bdo id='JTghY'><pre id='JTghY'><center id='JTghY'></center></pre></bdo></b><th id='JTghY'></th></span></q></dt></tr></i><div id='JTghY'><tfoot id='JTghY'></tfoot><dl id='JTghY'><fieldset id='JTghY'></fieldset></dl></div>
            • <bdo id='JTghY'></bdo><ul id='JTghY'></ul>
            • <tfoot id='JTghY'></tfoot>

              • <small id='JTghY'></small><noframes id='JTghY'>

                  <tbody id='JTghY'></tbody>
                本文介绍了使用 Maven 的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我已经将一个项目从 Eclipse 移植到 Maven,我需要设置一个环境变量来使我的项目工作.

                I've ported a project from Eclipse to Maven and I need to set an environment variable to make my project work.

                在 Eclipse 中,我转到运行 -"运行配置"并且,在环境"选项卡下,我设置了WSNSHELL_HOME".到值conf".

                In Eclipse, I go to "Run -> Run configurations" and, under the tab "environment", I set "WSNSHELL_HOME" to the value "conf".

                如何使用 Maven 做到这一点?

                How can I do this with Maven?

                推荐答案

                你可以直接在命令行传递,如

                You can just pass it on the command line, as

                mvn -DmyVariable=someValue install
                

                [更新]请注意,参数的顺序很重要 - 您需要在命令之前指定任何选项.[/Update]

                [Update] Note that the order of parameters is significant - you need to specify any options before the command(s).[/Update]

                在 POM 文件中,您可以将系统变量(在命令行或 pom 中指定)称为 ${myVariable},将环境变量称为 ${env.我的变量}.(感谢评论者的更正.)

                Within the POM file, you may refer to system variables (specified on the command line, or in the pom) as ${myVariable}, and environment variables as ${env.myVariable}. (Thanks to commenters for the correction.)

                好的,所以你想将你的系统变量传递给你的测试.如果 - 如我所料 - 你使用 Surefire 插件 进行测试,最好是在 pom 中指定所需的系统变量,在 plugins 部分,例如

                OK, so you want to pass your system variable to your tests. If - as I assume - you use the Surefire plugin for testing, the best is to specify the needed system variable(s) within the pom, in your plugins section, e.g.

                <build>
                    <plugins>
                        ...
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            ...
                            <configuration>
                                ...
                                <systemPropertyVariables>
                                    <WSNSHELL_HOME>conf</WSNSHELL_HOME>
                                </systemPropertyVariables>
                            </configuration>
                        </plugin>
                        ...
                    </plugins>
                </build>
                

                这篇关于使用 Maven 的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Maven JAVA_HOME environment variable is not defined correctly, but it is(Maven JAVA_HOME 环境变量未正确定义,但它是)
                Java System Environment Variable(Java 系统环境变量)
                Java -classpath option(Java -classpath 选项)
                Read environment variable in SpringBoot(在 SpringBoot 中读取环境变量)
                Tomcat 8 - context.xml use Environment Variable in Datasource(Tomcat 8 - context.xml 在数据源中使用环境变量)
                Issue with JAVA_HOME(JAVA_HOME 的问题)

                  <bdo id='GjQ2v'></bdo><ul id='GjQ2v'></ul>

                    <tfoot id='GjQ2v'></tfoot>
                  1. <small id='GjQ2v'></small><noframes id='GjQ2v'>

                        <legend id='GjQ2v'><style id='GjQ2v'><dir id='GjQ2v'><q id='GjQ2v'></q></dir></style></legend>
                          <tbody id='GjQ2v'></tbody>
                        • <i id='GjQ2v'><tr id='GjQ2v'><dt id='GjQ2v'><q id='GjQ2v'><span id='GjQ2v'><b id='GjQ2v'><form id='GjQ2v'><ins id='GjQ2v'></ins><ul id='GjQ2v'></ul><sub id='GjQ2v'></sub></form><legend id='GjQ2v'></legend><bdo id='GjQ2v'><pre id='GjQ2v'><center id='GjQ2v'></center></pre></bdo></b><th id='GjQ2v'></th></span></q></dt></tr></i><div id='GjQ2v'><tfoot id='GjQ2v'></tfoot><dl id='GjQ2v'><fieldset id='GjQ2v'></fieldset></dl></div>