소스 검색

[manager]fix不同系统开发和部署环境读取配置文件

tomsun28 4 년 전
부모
커밋
8ffde31707
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java

+ 2 - 2
manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java

@@ -123,11 +123,11 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
     public void run(String... args) throws Exception {
         // 读取app定义配置加载到内存中 define/app/*.yml
         Yaml yaml = new Yaml();
-        String classpath = this.getClass().getResource(File.separator).getPath();
+        String classpath = this.getClass().getClassLoader().getResource("").getPath();
         String defineAppPath = classpath + File.separator + "define" + File.separator + "app";
         File directory = new File(defineAppPath);
         if (!directory.exists() || directory.listFiles() == null) {
-            classpath = this.getClass().getResource("").getPath();
+            classpath = this.getClass().getResource(File.separator).getPath();
             defineAppPath = classpath + File.separator + "define" + File.separator + "app";
             directory = new File(defineAppPath);
             if (!directory.exists() || directory.listFiles() == null) {