故障現象:Tomcat8.5,單機多實例,有個實例有靜態資源需要使用軟連接訪問,每次重啟項目靜態資源就會訪問404錯誤。
按照網上方法設置如下:
在tomcat里context.xml文件里設置allowLinking="true"就可以打開軟連接,根據tomcat版本不同有不同的設置:
tomcat567版本:
<Context allowLinking="true" />
tomcat89版本:
<Context>
<Resources allowLinking="true" />
</Context>
設置以后,重啟項目,ROOT目錄軟連鏈接依然訪問報404錯誤,項目所有靜態資源訪問也報404錯誤。
經過新建實例多方面對比配置文件測試,發現是實例conf/server.xml里面
<Context path="" docBase="fileserver-api-1.0-SNAPSHOT/" debug="0" reloadable="true" crossContext="true"/>導致。
注釋此段配置文件以后,重啟項目軟連接和靜態資源都訪問正常。
贊
1
賞


