项目中需要配置Jetty虚拟目录,来放置一些图片,代码如下:
<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>
访问服务/upload时相当于访问/home/baseos/upload/文件路径
weblogic.xml代码参考如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-web-app
PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN"
"http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
<wls:weblogic-web-app xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<wls:virtual-directory-mapping>
<wls:local-path>/weblogic/</wls:local-path>
<wls:url-pattern>/myimages/*</wls:url-pattern>
</wls:virtual-directory-mapping>
</wls:weblogic-web-app>
访问服务/myimages时相当于访问/weblogic/myimages文件路径