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