public class PathKitExt extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private static String[] |
classPathDirs |
private static String |
locationPath |
private static String |
rootClassPath |
private static String |
webRootPath |
| 构造器和说明 |
|---|
PathKitExt() |
| 限定符和类型 | 方法和说明 |
|---|---|
private static String[] |
buildClassPathDirs() |
private static String |
buildRootClassPath() |
private static String |
buildWebRootPath() |
private static String |
getClassPathDirEndsWith_classes()
获取以 "classes" 结尾的 class path
|
static String[] |
getClassPathDirs() |
static String |
getLocationPath()
1:获取 PathKitExt 类文件所处 jar 包文件所在的目录,注意在 "非部署" 环境中获取到的
通常是 maven 本地库中的某个目录,因为在开发时项目所依赖的 jar 包在 maven 本地库中
这种情况不能使用
2:PathKitExt 自身在开发时,也就是未打成 jar 包时,获取到的是 APP_BASE/target/classes
这种情况多数不必关心,因为 PathKitExt 在使用时必定处于 jar 包之中
3:获取到的 locationPath 目录用于生成部署时的 config 目录,该值只会在 "部署" 环境下被获取
也用于生成 webRootPath、rootClassPath,这两个值也只会在 "部署" 时被获取
这样就兼容了部署与非部署两种场景
注意:该路径尾部的 "/" 或 "\\" 已被去除
|
static String |
getRootClassPath() |
static String |
getWebRootPath() |
private static String |
processRootClassPath(String path)
1:开发环境 path 会以 classes 结尾
2:打包以后的部署环境不会以 classes 结尾,约定一个合理的项目打包结构
暂时约定 APP_BASE/config 为 rootClassPath,因为要读取外部配置文件
|
private static String |
processWebRootPath(String path) |
static String |
removeSlashEnd(String path) |
private static String locationPath
private static String rootClassPath
private static String webRootPath
private static String[] classPathDirs
public PathKitExt()
public static String getLocationPath()
2:PathKitExt 自身在开发时,也就是未打成 jar 包时,获取到的是 APP_BASE/target/classes 这种情况多数不必关心,因为 PathKitExt 在使用时必定处于 jar 包之中
3:获取到的 locationPath 目录用于生成部署时的 config 目录,该值只会在 "部署" 环境下被获取 也用于生成 webRootPath、rootClassPath,这两个值也只会在 "部署" 时被获取 这样就兼容了部署与非部署两种场景
注意:该路径尾部的 "/" 或 "\\" 已被去除
public static String getRootClassPath()
private static String buildRootClassPath()
private static String getClassPathDirEndsWith_classes()
private static String processRootClassPath(String path)
2:打包以后的部署环境不会以 classes 结尾,约定一个合理的项目打包结构 暂时约定 APP_BASE/config 为 rootClassPath,因为要读取外部配置文件
public static String removeSlashEnd(String path)
public static String getWebRootPath()
private static String buildWebRootPath()
private static String processWebRootPath(String path)
public static String[] getClassPathDirs()
private static String[] buildClassPathDirs()
Copyright © 2024. All rights reserved.