日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

spring项目启动慢问题

發布時間:2023/12/18 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 spring项目启动慢问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

問題:

這個問題在我學spring框架的時候就出現過,當時啟動緩慢一直卡在控制臺項目。但是耐心等是可以出來的。當我學到springMVC的時候又是這樣,而且tomcat啟動打印日志又卡住了如下圖

忍無可忍我上網搜了好多但是都問題不匹配。我下面又自己嘗試是卡在那個環節了。
因為我學spring的時候就遇到過,所以下意識認為是spring框架配置文件的問題,于是在這個springMVC的入門程序中我將servlet掃描springMVC配置文件的部分注釋掉試著再次啟動,果不其然速度刷刷的啟動了。

所以問題出現在spring配置文件。

解決:

我們將springmvc配置文件中的約束換成下面這個即可:

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsd">

我以前的是這樣的,區別其實就是引入spring-context和spring-mvc的順序不一樣,可能這會導致尋找不到對應的xsd所以導致項目卡住:

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttps://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd">

學習自:
https://my.oschina.net/ouyangtaohong/blog/810037

這里面的約束加著springMVC的版本,我試過不可以,所以將版本號去掉也成功了。

總結:

就像大佬說的,在spring啟動的時候,會從spring配置文件中配置的xsd地址下載信息,如果你沒有配置版本信息,則會從你的本地加載。如果寫了和你引入的spring版本信息相同的版本,則也會從本地加載,如果不和你引入的匹配,則從外網下載。

這是約束寫的不對導致的啟動緩慢問題,當然也可能是其他原因,這只是我的一種情況。

如有錯誤請指出謝謝!

總結

以上是生活随笔為你收集整理的spring项目启动慢问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。