如何将环境变量添加到maven-jetty-plugin

时间:2012-11-29 02:29:57

标签: maven jetty maven-plugin maven-jetty-plugin

我正在使用maven jetty插件,如下所示:

 <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>

我的网络应用程序在ec2上运行,我们在其中设置了一些环境变量(如CLOUD_DEV_PHASE)。我想知道是否有办法在pom文件中放置CLOUD_DEV_PHASE的虚拟值,因此您不必在系统上执行此操作。有没有办法做到这一点?

我正在寻找类似于

的东西
CLOUD_DEV_PHASE=dev mvn jetty:run

4 个答案:

答案 0 :(得分: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

答案 1 :(得分: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>

此致

答案 2 :(得分: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>

答案 3 :(得分:0)

我在一个论坛上看到了这个。我希望它适用于你。

// When any of my buttons are pressed, push the next view
- (IBAction)buttonPressed:(id)sender
{
    [self performSegueWithIdentifier:@"MySegue" sender:sender];
}

// This will get called too before the view appears
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
    {
        // Get reference to the destination view controller
        YourViewController *vc = [segue destinationViewController];

        // Pass any objects to the view controller here, like...
        [vc setMyObjectHere:object];
    }
}