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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值