0

I am using the maven jetty pluggin as follows:

 <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>8.1.5.v20120716</version>
    <configuration>
      <stopKey>1</stopKey>
      <stopPort>9999</stopPort>
    </configuration>
  </plugin>

My web app is running on ec2 where we have a few environment variables setup (like CLOUD_DEV_PHASE). I was wondering if there is a way to put a dummy value for CLOUD_DEV_PHASE in the pom file so you don't have to do it on your system. Is there a way to do this?

I am looking for something similar to

CLOUD_DEV_PHASE=dev mvn jetty:run
4

4 回答 4

3

你的意思是添加系统属性?像这样:

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <configuration>
    <systemProperties>
      <systemProperty>
         <name>CLOUD_DEV_PHASE</name>
         <value>dummy</value>
       </systemProperty>
    </systemProperties>
    <webApp>
      <contextPath>/test</contextPath>
    </webApp>
   </configuration>
</plugin>

有关更多信息,请查看:http ://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin#Setting_System_Properties

于 2012-11-29T02:37:25.860 回答
1

我不确定是否完全理解您的问题,但如果您需要设置环境变量,我通常使用 exec 插件:http: //mojo.codehaus.org/exec-maven-plugin/

以下目标:http: //mojo.codehaus.org/exec-maven-plugin/exec-mojo.html

像这样:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
      <execution>
        <id>setEnvVar</id>
        <phase>initialize</phase>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <executable>export</executable>
      <arguments>
        <argument>CLOUD_DEV_PHASE=Something</argument>
      </arguments>
    </configuration>
  </plugin>

问候

于 2012-11-29T02:37:52.900 回答
1

我在一个论坛看到这个。我希望它对你有用。

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${jetty.version}</version>
    <configuration>
      ...

      <env>
         <wibble>pencil</wibble>
         <foo>bar</foo>
         <black>white</black>
      </env>

      ...

    </configuration>
</plugin>
于 2016-05-19T06:35:37.750 回答
0

我会尝试env.CLOUD_DEV_PHASE在项目部分设置属性:

<project>
    ...
    <properties>
        <env.CLOUD_DEV_PHASE>dev</env.CLOUD_DEV_PHASE>
    </properties>
    ...
</project>

或在 Jetty 插件配置中:

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <configuration>
    ...
    <systemProperties>
      <systemProperty>
         <name>env.CLOUD_DEV_PHASE</name>
         <value>dev</value>
       </systemProperty>
    </systemProperties>
   </configuration>
</plugin>
于 2013-03-13T16:17:39.833 回答