分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

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

发布时间:2023-09-06 02:24责任编辑:苏小强关键词:jsjsonclass

具体报错信息如下

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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved