6

我正在使用 Maven3 构建一个 Web 应用程序并通过mvn jetty:run-war. 现在我想在系统浏览器中从我的 maven 构建中打开网络应用程序。

4

3 回答 3

4

我在 os windows 上解决了我的问题,这是我目前唯一的构建系统。启动码头服务器并托管我的网络应用程序后,构建通过 antrun 进行启动调用:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
      <execution>
        <id>Run URL in system browser.</id>
        <phase>install</phase>
        <configuration>
          <target>
            <exec executable="start" vmlauncher="false">
              <arg line="http://localhost:8080/rap?startup=entrypoint"/>
            </exec>
          </target>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
于 2012-10-08T11:35:30.060 回答
1

作为我的bck2brwsr VM工作的一部分,我编写了一个 Maven 插件,可以在每个平台/JDK 上打开浏览器。它可用于显示项目中的任何静态页面。以下示例打开带有pom.xml文件内容的浏览器:

<plugin>
    <groupId>org.apidesign.bck2brwsr</groupId>
    <artifactId>bck2brwsr-maven-plugin</artifactId>
    <version>0.22</version>
    <executions>
        <execution>
            <id>show-a-file</id>
            <phase>verify</phase>
            <goals>
                <goal>show</goal>
            </goals>
            <configuration>
                <directory>${basedir}</directory>
                <startpage>pom.xml</startpage>
            </configuration>
        </execution>
    </executions>
</plugin>

我知道打开静态页面并不完美,但它可以包含适当的重定向,对吧?此外,如果有兴趣,可以轻松改进插件以打开任何 URL。欢迎拉取请求

于 2017-12-20T07:02:03.980 回答
-1
  1. 使用码头服务器。build在 pom.xml 中的标记下添加 Jetty 插件,如下所示:

     <plugins>
        <plugin>
          <groupId>org.mortbay.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <configuration>
            <scanIntervalSeconds>10</scanIntervalSeconds>
            <webApp>
              <contextPath>/shinchan</contextPath>
            </webApp>
          </configuration>
        </plugin>
    <!-- more plugin tags if any -->
    <plugins>
    
  2. 现在使用

      mvn clean install jetty:run
    
  3. 这将在端口 8080 启动 Jetty 服务器,您可以http://localhost:8080/shinchan在执行 mvn 命令的机器上使用 URL 访问。

PS:
有关更多详细信息,请在此处阅读 Jetty wiki:http: //wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin
您可能需要考虑jetty:deploy-war,但我认为这是一种矫枉过正。

于 2012-10-04T11:52:31.420 回答