|
@@ -17,6 +17,7 @@ import java.nio.file.Files;
|
|
|
public class EnvironmentAwareResourceLoader {
|
|
|
/**
|
|
|
* 智能加载资源(自动判断环境)
|
|
|
+ *
|
|
|
* @param relativePath 资源相对路径(如:temp/example.txt)
|
|
|
* @return 文件输入流
|
|
|
* @throws IOException
|
|
@@ -25,7 +26,7 @@ public class EnvironmentAwareResourceLoader {
|
|
|
if (isRunningInJar()) {
|
|
|
// 服务器环境:从JAR同级目录加载
|
|
|
File jarDir = getJarDirectory();
|
|
|
- File targetFile = new File(jarDir, relativePath);
|
|
|
+ File targetFile = new File(jarDir, "cjdTemp/" + relativePath);
|
|
|
|
|
|
if (!targetFile.exists()) {
|
|
|
throw new FileNotFoundException("服务器环境文件未找到: " + targetFile.getAbsolutePath());
|
|
@@ -34,7 +35,7 @@ public class EnvironmentAwareResourceLoader {
|
|
|
|
|
|
} else {
|
|
|
// 开发环境:从resources目录加载
|
|
|
- ClassPathResource classPathResource = new ClassPathResource(relativePath);
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("temp/cjd/" + relativePath);
|
|
|
return classPathResource.getInputStream();
|
|
|
}
|
|
|
}
|