首页 > Web开发 > 详细

ueditor百度富文本编辑器linux下报错: class path resource [config.json] cannot be resolved to absolute file path because it does not reside in the file system

时间:2018-11-30 13:21:52      阅读:1812      评论:0      收藏:0      [点我收藏+]

具体报错信息如下

java.io.FileNotFoundException: class path resource [config.json] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/home/java/wcq-new-server/wcq/wcq-admin/target/wcq-admin.jar!/BOOT-INF/classes!/config.json

    at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:217)
    at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:180)
    at com.wcgj.wcq.admin.common.ueditor.ConfigManager.initEnv(ConfigManager.java:173)
    at com.wcgj.wcq.admin.common.ueditor.ConfigManager.<init>(ConfigManager.java:46)
    at com.wcgj.wcq.admin.common.ueditor.ConfigManager.getInstance(ConfigManager.java:60)

一番搜索后发现问题所在:是用了 ResourceUtils.getFile("classpath:config.json") ,这个方法只是从类路径下获取文件,无法从jar包中获取,所以打成jar包后发布到linuxs系统,就报错找不到文件了.

解决方案

使用 ClassPathResource classPathResource = new ClassPathResource("config.json"); 来获取文件,这个方法可以直接从jar包中抓取文件

 

具体代码修改如下:

技术分享图片

 

ueditor百度富文本编辑器linux下报错: class path resource [config.json] cannot be resolved to absolute file path because it does not reside in the file system

原文:https://www.cnblogs.com/findtasy/p/10043273.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!