maven中tomcat和jetty嵌入式插件设置虚拟目录

maven中tomcat和jetty嵌入式插件设置虚拟目录.

maven-jetty-plugin版本9.2.10.v20150310

 

<plugin>
	<groupId>org.eclipse.jetty</groupId>
	<artifactId>jetty-maven-plugin</artifactId>
	<version>${jetty.version}</version>
	<configuration>
		<encoding>UTF-8</encoding>
		<scanIntervalSeconds>10</scanIntervalSeconds>
		<contextXml>${project.basedir}/src/test/resources/jetty-context.xml</contextXml>
		<!-- <jettyXml>${project.basedir}/src/test/resources/jetty.xml</jettyXml> -->
		 <webAppConfig>  
			 <defaultsDescriptor>${project.basedir}/src/test/resources/webdefault.xml</defaultsDescriptor>  
		</webAppConfig>    
		<stopKey>foo</stopKey>
		<stopPort>9999</stopPort>
		<webApp>
			<contextPath>/</contextPath>
		</webApp>
		<!-- 额外监听目录 -->
		<contextHandlers>
			<!-- 附件目录服务 -->
			<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
				<contextPath>/upload</contextPath>
				<resourceBase>/home/baseos/upload/</resourceBase>
			</contextHandler>
		</contextHandlers>
	</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>

 

 

tomcat7-maven-plugin版本2.2 直接在pom中配置的资料未找到.

所以只能采取另外的做法,使用server.xml

增加server.xml文件.

 

 

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <Listener className="org.apache.catalina.core.JasperListener"/>
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
  <GlobalNamingResources>
    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector connectionTimeout="20000" port="80" protocol="HTTP/1.1" redirectPort="8443"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>

    <Engine defaultHost="localhost" name="Catalina">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>

      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
             <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>
	    <!-- 增加虚拟目录配置-->
             <Context docBase="d:/home/baseos/upload/" path="/upload" reloadable="true"/>
      </Host>
    </Engine>
  </Service>
</Server>

tomcat7-maven-plugin 中增加这个配置文件设置

 

<plugin>
	<groupId>org.apache.tomcat.maven</groupId>
	<artifactId>tomcat7-maven-plugin</artifactId>
	<version>2.2</version>
	<configuration>
		<path>/</path>
		<port>80</port>
		<uriEncoding>UTF-8</uriEncoding>
		<server>tomcat7</server>
		<serverXml>${project.basedir}/src/test/resources/server.xml</serverXml>
	</configuration>
</plugin>

转载于:https://my.oschina.net/u/2525078/blog/732837

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值