File path = null; try { path = new File(ResourceUtils.getURL("classpath:").getPath()); } catch (FileNotFoundException e) { } if (path == null || !path.exists()) { path = new File(""); } String pathStr = path.getAbsolutePath(); // 如果是在eclipse中运行,则和target同级目录,如果是jar部署到服务器,则默认和jar包同级 pathStr = pathStr.replace("/target/classes", "/upload"); File upload = new File(pathStr); if (!upload.exists()) { upload.mkdirs(); }
springboot 项目绝对路径
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Spring boot自动装配实现原理
原創
2024-05-16 23:48:07
教你如何搞定springboot集成kafka
原創
2024-05-16 22:58:25
Koupleless 内核系列|模块化隔离与共享带来的收益与挑战
原創
2024-05-15 23:18:46
Spring cloud bootstrap context机制
原創
2024-05-15 11:50:16
Spring cloud 服务注册发现
原創
2024-05-15 11:50:14
记一次特别的未授权访问
原創
2024-05-13 23:18:59
Spring Boot3,启动时间缩短 10 倍!
原創
2024-05-13 02:20:47
一种极简单的SpringBoot单元测试方法| 京东零售技术团队
原創
2024-05-10 00:30:06
关于Java Chassis 3的契约优先(API First)开发
原創
2024-05-09 11:21:06
Python 爬虫:Spring Boot 反爬虫的成功案例
原創
2024-05-07 23:26:04
springboot连接Redis报NOAUTH Authentication required
原創
2024-05-06 11:35:20
通义灵码实战系列:一个新项目如何快速启动,如何维护遗留系统代码库?
原創
2024-04-30 21:12:20
SpringBoot配置HTTPS及开发调试
原創
2024-04-29 21:38:23
Spring Boot应用中如何动态指定数据库,实现不同用户不同数据库的场景
原創
2024-04-26 21:37:12