最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringMVC Idea 搭建 部署war的詳細(xì)過程

 更新時(shí)間:2025年01月17日 16:22:09   作者:葒色海灣  
本文介紹了如何在IntelliJ IDEA中使用Maven模板創(chuàng)建一個(gè)Web項(xiàng)目,并詳細(xì)說明了如何配置web.xml、創(chuàng)建springmvc-servlet.xml和application.properties文件,以及如何使用Maven打包生成WAR文件并部署到Tomcat服務(wù)器,感興趣的朋友跟隨小編一起看看吧

1.創(chuàng)建 Idea項(xiàng)目

使用Maven模板 創(chuàng)建 webApp模板項(xiàng)目

2.導(dǎo)入依賴 

<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">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.x</groupId>
  <artifactId>jetty-x-file-server</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>jetty-x-file-server Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
<!--    <dependency>-->
<!--      <groupId>jakarta.servlet</groupId>-->
<!--      <artifactId>jakarta.servlet-api</artifactId>-->
<!--      <version>6.0.0</version>-->
<!--      <scope>provided</scope>-->
<!--    </dependency>-->
<!--    <dependency>-->
<!--      <groupId>org.springframework</groupId>-->
<!--      <artifactId>spring-webmvc</artifactId>-->
<!--      <version>6.2.0</version>-->
<!--    </dependency>-->
<!--    <dependency>-->
<!--      <groupId>com.fasterxml.jackson.core</groupId>-->
<!--      <artifactId>jackson-databind</artifactId>-->
<!--      <version>2.17.2</version>-->
<!--    </dependency>-->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.9.8</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>5.3.18</version>
    </dependency>
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.11.0</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>jetty-x-file-server</finalName>
  </build>
</project>

3.web.xml更新至4.0

并且注冊DispatcherServlet

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
  <!--1.注冊DispatcherServlet -->
  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!--2.關(guān)聯(lián)一個(gè)springmvc的配置文件:【servlet-name】-servlet.xml -->
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springmvc-servlet.xml</param-value>
    </init-param>
    <!--3.啟動(dòng)級別=1  -->
    <load-on-startup>1</load-on-startup>
  </servlet>
  <!--4. / 匹配所有的請求:(不包括.jsp) -->
  <!--5. /* 匹配所有的請求:(包括.jsp) -->
  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

4.springmvc-servlet.xml

在resource目錄下創(chuàng)建

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        https://www.springframework.org/schema/context/spring-context.xsd"
>
    <!--1.注解驅(qū)動(dòng)  若用jackson需要在用properties來注入-->
    <!--    JSON亂碼問題-->
    <mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <constructor-arg value="UTF-8"/>
            </bean>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper">
                    <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
                        <property name="failOnEmptyBeans" value="false"/>
                    </bean>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    <!--2.靜態(tài)資源-->
    <mvc:default-servlet-handler/>
    <!--3.掃描包    -->
    <context:component-scan base-package="com.x.jettyxfileserver"/>
    <!-- 文件上傳配置   -->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!--         請求的編碼格式:必要和jsp的pageEncoding屬性一致,以便正確讀取表單的內(nèi)容,默認(rèn)為ISO-8859-1   -->
        <property name="defaultEncoding" value="utf-8"/>
        <!--           上傳文件大小上限,單位為字節(jié)  (10485760=10M) -->
        <property name="maxUploadSize" value="10485760"/>
        <property name="maxInMemorySize" value="40960"/>
    </bean>
    <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:application.properties</value>
            </list>
        </property>
    </bean>
</beans>

5.創(chuàng)建application.properties

在resource目錄下

filePath=${FILE_PATH:C:\\Program Files\\jetty\\jetty-distribution-9.2.1.v20140609(ssl)\\webapps\\ROOT\\html\\resources}
#filePath=C:\\Users\\RJ\\Desktop\\file

配置好tomcat

選擇exploded的 

配置應(yīng)用上下文,保存就可以了

6.maven打包

直接 clean package 就好了

放入 tomcat webApps

目錄下。它會(huì)自動(dòng)解包,生成文件夾項(xiàng)目

到此這篇關(guān)于SpringMVC Idea 搭建 部署war的文章就介紹到這了,更多相關(guān)SpringMVC Idea 部署war內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java并發(fā)編程之如何優(yōu)雅關(guān)閉鉤子Shutdown Hook

    Java并發(fā)編程之如何優(yōu)雅關(guān)閉鉤子Shutdown Hook

    這篇文章主要為大家詳細(xì)介紹了Java如何實(shí)現(xiàn)優(yōu)雅關(guān)閉鉤子Shutdown Hook,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-04-04
  • java實(shí)現(xiàn)簡單猜數(shù)字游戲

    java實(shí)現(xiàn)簡單猜數(shù)字游戲

    這篇文章主要介紹了java實(shí)現(xiàn)簡單猜數(shù)字游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • springboot 啟動(dòng)如何排除某些bean的注入

    springboot 啟動(dòng)如何排除某些bean的注入

    這篇文章主要介紹了springboot 啟動(dòng)如何排除某些bean的注入方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-08-08
  • 用Java實(shí)現(xiàn)小球碰壁反彈的簡單實(shí)例(算法十分簡單)

    用Java實(shí)現(xiàn)小球碰壁反彈的簡單實(shí)例(算法十分簡單)

    下面小編就為大家?guī)硪黄肑ava實(shí)現(xiàn)小球碰壁反彈的簡單實(shí)例(算法十分簡單)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-08-08
  • springboot實(shí)用配置詳細(xì)圖文教程

    springboot實(shí)用配置詳細(xì)圖文教程

    SpringBoot從本質(zhì)上來說就是Spring,它通過了一些自己的特性幫助我們簡化了Spring應(yīng)用程序的開發(fā),下面這篇文章主要給大家介紹了關(guān)于springboot實(shí)用配置的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2023-05-05
  • 解決Lombok使用@Builder無法build父類屬性的問題

    解決Lombok使用@Builder無法build父類屬性的問題

    這篇文章主要介紹了解決Lombok使用@Builder無法build父類屬性的問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • 2021最新IDEA的各種快捷鍵匯總

    2021最新IDEA的各種快捷鍵匯總

    掌握idea的各種快捷鍵,可以幫助我們開發(fā)程序,今天小編給大家?guī)韼追N比較常用的idea快捷鍵及一些快捷鍵介紹,對idea快捷鍵相關(guān)知識(shí),感興趣的朋友一起看看吧
    2021-05-05
  • Java高效實(shí)現(xiàn)電商產(chǎn)品排序?qū)崙?zhàn)

    Java高效實(shí)現(xiàn)電商產(chǎn)品排序?qū)崙?zhàn)

    這篇文章主要為大家介紹了Java高效實(shí)現(xiàn)電商產(chǎn)品排序?qū)崙?zhàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11
  • Java8的Lambda和排序

    Java8的Lambda和排序

    這篇文章主要介紹了Java8的Lambda和排序,對數(shù)組和集合進(jìn)行排序是Java 8 lambda令人驚奇的一個(gè)應(yīng)用,我們可以實(shí)現(xiàn)一個(gè)Comparators來實(shí)現(xiàn)各種排序,下面文章將有案例詳細(xì)說明,想要了解得小伙伴可以參考一下
    2021-11-11
  • Java圖形界面超實(shí)用使用教程

    Java圖形界面超實(shí)用使用教程

    在Java編程中圖形界面應(yīng)用程序是非常常見和重要的一部分,下面這篇文章主要給大家介紹了關(guān)于Java圖形界面的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-01-01

最新評論

曲靖市| 尼勒克县| 南漳县| 陆河县| 娱乐| 偏关县| 安平县| 鄱阳县| 会泽县| 福泉市| 五家渠市| 定结县| 广东省| 荣成市| 乌拉特前旗| 玛多县| 达日县| 栖霞市| 瓦房店市| 绥棱县| 前郭尔| 陕西省| 龙山县| 开化县| 金秀| 威远县| 双鸭山市| 陆川县| 黔西| 霍州市| 分宜县| 奉节县| 甘肃省| 新蔡县| 蒙山县| 宜川县| 铜山县| 厦门市| 合川市| 黄浦区| 凌源市|