有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java运行Jetty Maven插件时如何使用MovedContextHandler?

我想在Maven构建中使用的嵌入式Jetty服务器中设置一个永久HTTP重定向。我正在使用Maven 3.0.4和jetty Maven插件版本9.0.6。v20130930。Jetty documentation清楚地演示了如何在非嵌入式Jetty实例中设置它,但我不太清楚在Maven内部运行时如何设置它

下面是我用于重定向的上下文XML文件:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">

<Configure class="org.eclipse.jetty.server.handler.MovedContextHandler">
  <Set name="contextPath">/permanently-moved-feeds</Set>
  <Set name="newContextURL">/</Set>
  <Set name="permanent">true</Set>
  <Set name="discardPathInfo">false</Set>
  <Set name="discardQuery">false</Set> 
</Configure>

以下是相关的Maven pom。xml配置:

    <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>

        <configuration>
          <resourcesBases>src/main/webapp,src/main/webapp/test-feeds</resourcesBases>                 
        </configuration>
        <executions>
         <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <scanIntervalSeconds>10</scanIntervalSeconds>
              <daemon>true</daemon>
            </configuration>
          </execution>
          <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
    </plugin>    

因此,我的具体问题是如何配置jetty maven插件,以便jetty知道在第一个XML示例中从何处找到上下文XML文件


共 (0) 个答案