公司项目所有静态资源全部放在项目根路径下,所以每次部署都会覆盖掉,用户经常会上传新的图片,这就导致很大的问题了
处理如下:eclipse导入项目,打包部署,运行,
tomcat的conf目录下的server.xml中加入
<Context crossContext="true" docBase="C:\Users\Rey-hakin\Downloads" path="/upload" reloadable="true">Context>
然后eclipse中的server中也加入配置如图,不配置虚拟路径不生效
ok eclipse搞没问题。确定我的解决方案时可以的
下面换成idea,中间踩坑无数我就不说了,直接上解决方案
为支持项目静态资源路径迁移,本地 项目测试部署需要配置以下内容
1:打开本地tomcat安装地址,找到conf/server.xml 在节点下增加以下配置
注:docBase路径可自行配置,但要匹配uploadfile.properties中的uploadpath值
端口和项目pom里设置保持一致
配置tomcat-users.xml
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="password" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
Maven setting.xml配置
3:添加TomCat Server
Deploy applications configured in Tomcat instance 这个勾选上
设置Application context路基,和tomcat里server.xml配置的path值一致
ok idea上也没问题,下面你就要放到服务器了。
=========================================
结果
404 你敢信~~~~反正我是信了
然后各种查各种找,百度,谷歌都找了试了N种方法
中间莫名奇妙的来个一次这个错误
20-Jun-2017 07:47:55.280 警告 [GitSCM.onLoaded] org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/WEB-INF/classes/org/jenkinsci/plugins/durabletask/Messages_zh.properties] to the cache for web application [] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
参考解决:
http://blog.csdn.net/xiaocao9903/article/details/53393473
中间还报了一会403,我以为看到了成功的曙光,然鹅。。。
报403时参考了这几个:
http://oldboy.blog.51cto.com/2561410/581383/
http://www.programgo.com/article/71342920048/
最后,看到这篇博客
http://www.voidcn.com/blog/lawmansoft/article/p-3048338.html
感谢!!!
在tomcat文件夹的conf”catalina”localhost
对于Tomcat6版本及其以上,需要自己在tomcat下的catalina/localhost文件夹下新建一个xml文件,文件名就是你虚拟路径配置的名字,例如我的即使upload.xml
<Context
docBase="换成你的路径"
reloadable="true">
Context>
终于成功!!!
方法永远比问题多,坚持不放弃,成功属于努力的那个你。