Maven 添加 Tomcat 插件


若想在 Maven 中使用 Tomcat 服務器,需要在 pom.xml 文件中的 <build></build> 標簽中添加以下代碼

<!-- Maven項目編譯插件 -->
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>    <!-- 不指定時默認采用最新插件版本 -->
            <configuration>
                <!-- 根據實際情況設置 JDK -->
                <source>1.7</source>    <!-- 源代碼使用的開發版本 -->
                <target>1.7</target>    <!-- 需要生成的目標class文件的編譯版本 -->
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <!-- Tomcat 插件配置 -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <!-- 使用內置的模擬Tomcat服務器 -->
                <path>/SpringMVC_170422_RESTful_CRUD</path>
                <uriEncoding>UTF-8</uriEncoding>
                <port>9527</port>
                <mode>context</mode>
                <contextReloadable>true</contextReloadable>
            </configuration>
        </plugin>
    </plugins>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM