jetty
<build>
<finalName>/xxx</finalName>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.9.v20130131</version>
<configuration>
<webApp>
<contextPath>/xxx</contextPath>
</webApp>
<connectors>
<connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
<port>8081</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
<connector implementation="org.eclipse.jetty.server.ssl.SslSocketConnector">
<port>8443</port>
<maxIdleTime>60000</maxIdleTime>
<password>123456</password>
<keyPassword>123456</keyPassword>
<keystore>${project.basedir}/src/test/resources/jetty.keystore</keystore>
</connector>
</connectors>
<systemProperties>
<systemProperty>
<!--一般服務器默認是ISO-8859-1編碼-->
<name>org.eclipse.jetty.util.URI.charset</name>
<value>ISO-8859-1</value>
</systemProperty>
</systemProperties>
<!-- 從8.x開始,如果你的web項目中不包含數據庫訪問(或者說沒有事務管理器)的話,在其啓動時會提示找不到事務管理器
啓動過程會暫停十幾秒,在反覆調試代碼時很浪費時間,因此加入如下的配置,這個配置文件沒有其他用處-->
<contextXml>${project.basedir}/src/test/resources/jetty-context.xml</contextXml>
</configuration>
</plugin>
<!-- 密鑰庫生成器 也可以使用jdk keytool.exe生成密鑰庫-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>generate-resources</phase>
<id>clean</id>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<phase>generate-resources</phase>
<id>genkey</id>
<goals>
<goal>generateKeyPair</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>${project.basedir}/src/test/resources/jetty.keystore</keystore>
<dname>CN=xxx,OU=xxx,O=xxx,L=xxx,ST=xxx,C=cn</dname>
<keypass>123456</keypass>
<storepass>123456</storepass>
<alias>jetty8</alias>
<keyalg>RSA</keyalg>
</configuration>
</plugin>
</plugins>
</build>
jetty-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>.*/.*jsp-api-[^/]\.jar$|./.*jsp-[^/]\.jar$|./.*taglibs[^/]*\.jar$</Arg>
</Call>
</Configure>
1、jetty 9.0以後就不能直接配置在pom文件中。
2、jetty的keystore需要指定RSA算法。
3、每次編譯的時候,keytool-maven-plugin都會重新生成keystore,所以,可以再生成keystore後刪除這個插件配置。
4、org.eclipse.jetty.server.bio.SocketConnector和org.eclipse.jetty.server.ssl.SslSocketConnector不會鎖定資源文件(html、css、js、圖片等),但是org.eclipse.jetty.server.nio.SelectChannelConnector和org.eclipse.jetty.server.ssl.SslSelectChannelConnector會鎖定資源文件,兩者是表示http和https的connector.
Tomcat
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/ice</path>
<port>9090</port>
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>