maven jetty7 插件设置

jetty-maven-plugin设置:

<plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>7.1.5.v20100705</version>
        <configuration>
          <webDefaultXml>webdefault.xml</webDefaultXml>
          <scanIntervalSeconds>0</scanIntervalSeconds>
          <webAppSourceDirectory>src/main/webapp</webAppSourceDirectory>
          <webAppConfig>
            <contextPath>/test</contextPath>
            <!-- <tempDirectory>${project.build.directory}/</tempDirectory> -->
            <jettyEnvXml>${basedir}/jetty-env.xml</jettyEnvXml>
          </webAppConfig>
          <scanTargetPatterns>
            <scanTargetPattern>
              <directory>src/main/webapp/WEB-INF</directory>
              <excludes>
                <exclude>**/*.jsp</exclude>
              </excludes>
              <includes>
                <include>**/*.properties</include>
                <include>**/*.xml</include>
              </includes>
            </scanTargetPattern>
          </scanTargetPatterns>

          <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
              <port>8080</port>
              <host>localhost</host>
              <maxIdleTime>60000</maxIdleTime>
            </connector>
            <!--<connector implementation="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
              <port>8443</port>
              <keystore>src/test/resources/server.keystore</keystore>
              <keyPassword>123456</keyPassword>
              <password>123456</password>
            </connector>
          --></connectors>

          <stopKey>foo</stopKey>
          <stopPort>9999</stopPort>
          <systemProperties>
            <systemProperty>
              <name>org.eclipse.jetty.util.URI.charset</name>
              <value>GBK</value>
            </systemProperty>
          </systemProperties>
        </configuration>
        <executions>
          <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <scanIntervalSeconds>0</scanIntervalSeconds>
              <daemon>true</daemon>
            </configuration>
          </execution>
          <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

 

 

web.xml如采用2.5规范需如下设置: 添加 metadata-complete="true" 属性,否则jetty会扫描代码中的注解.

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	version="2.5" metadata-complete="true">

DBCP数据源设置jetty-env.xml:

<?xml version="1.0" encoding="utf-8"?>  
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"  
"http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <New id="dataSource" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg>devDs</Arg>
    <Arg>
      <New class="org.apache.commons.dbcp.BasicDataSource">
        <Set name="driverClassName">oracle.jdbc.driver.OracleDriver</Set>
        <Set name="url">jdbc:oracle:thin:@localhost:1521:dev</Set>
        <Set name="username">dev</Set>
        <Set name="password">dev</Set>
      </New>
    </Arg>
  </New>
</Configure>

 URL编码设置:

添加运行参数  -Dorg.eclipse.jetty.util.URI.charset=GBK

或设置 systemProperty.

你可能感兴趣的:(maven jetty7 插件设置)