maven pom 配置jetty启动,设置虚拟路径
原创    iwantyou    发表于:2018-03-01 15:59:28
  阅读 :169   收藏   编辑

参考配置如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

        ......

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <jdk.version>1.8</jdk.version>
        <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
    </properties>
    <dependencies>
        ......
    </dependencies>
    <build>
        <finalName>test_pro</finalName>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.10.v20150310</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <httpConnector>
                        <port>8080</port>
                    </httpConnector>
                    <webApp>
                        <contextPath>/test_pro</contextPath>
                    </webApp>
                    <contextHandlers>
                        <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                            <!--设置虚拟路径  -->
                            <contextPath>/test_pro/upload</contextPath>
                            <resourceBase>G:/upload_dir/upload</resourceBase>
                        </contextHandler>
                    </contextHandlers>
                </configuration>
            </plugin>

            <!-- 集成JDK编译插件compiler, 设定编译时用的JDK版本 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>

        </plugins>
    </build>


</project>
评论
条评论