Forráskód Böngészése

down矢量数据调整并发异常

chenendian 2 hete
szülő
commit
e49c49a8f0

+ 41 - 11
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/config/GeoToolsEpsgRuntimeCheck.java

@@ -17,22 +17,52 @@ public class GeoToolsEpsgRuntimeCheck implements ApplicationRunner {
     private static final String EPSG_FACTORY_CLASS =
     private static final String EPSG_FACTORY_CLASS =
             "org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory";
             "org.geotools.referencing.factory.epsg.hsql.ThreadedHsqlEpsgFactory";
 
 
+//    @Override
+//    public void run(ApplicationArguments args) {
+//        try {
+//            Class.forName(EPSG_FACTORY_CLASS);
+//            ThreadedHsqlEpsgFactory hsqlFactory = new ThreadedHsqlEpsgFactory();
+//            ReferencingFactoryFinder.addAuthorityFactory(hsqlFactory);
+//            ReferencingFactoryFinder.scanForPlugins();
+//            Set<String> codes = CRS.getSupportedCodes("EPSG");
+//            Object authorityFactory = CRS.getAuthorityFactory(true);
+//            CoordinateReferenceSystem crs = CRS.decode("EPSG:4490");
+//            CoordinateReferenceSystem hsqlCrs = hsqlFactory.createCoordinateReferenceSystem("4490");
+//            log.info("GeoTools EPSG运行时检查通过:factoryClass={}, authorityFactory={}, has4490={}, crs={}, hsqlCrs={}",
+//                    EPSG_FACTORY_CLASS, authorityFactory.getClass().getName(), codes.contains("4490"),
+//                    crs.getName(), hsqlCrs.getName());
+//        } catch (Exception e) {
+//            log.error("GeoTools EPSG:4490运行时检查失败,请确认运行包包含gt-epsg-hsql、hsqldb,且没有通过loader.path或外部lib混入其他版本GeoTools依赖", e);
+//        }
+
+//
+//    }
+
+
+
     @Override
     @Override
     public void run(ApplicationArguments args) {
     public void run(ApplicationArguments args) {
         try {
         try {
-            Class.forName(EPSG_FACTORY_CLASS);
-            ThreadedHsqlEpsgFactory hsqlFactory = new ThreadedHsqlEpsgFactory();
-            ReferencingFactoryFinder.addAuthorityFactory(hsqlFactory);
-            ReferencingFactoryFinder.scanForPlugins();
-            Set<String> codes = CRS.getSupportedCodes("EPSG");
-            Object authorityFactory = CRS.getAuthorityFactory(true);
+            // 1. 检查工厂是否可用
+            boolean available = CRS.getAuthorityFactory(true) != null;
+
+            // 2. 解码目标坐标系(这一步会触发 HSQL backing store 的惰性初始化)
             CoordinateReferenceSystem crs = CRS.decode("EPSG:4490");
             CoordinateReferenceSystem crs = CRS.decode("EPSG:4490");
-            CoordinateReferenceSystem hsqlCrs = hsqlFactory.createCoordinateReferenceSystem("4490");
-            log.info("GeoTools EPSG运行时检查通过:factoryClass={}, authorityFactory={}, has4490={}, crs={}, hsqlCrs={}",
-                    EPSG_FACTORY_CLASS, authorityFactory.getClass().getName(), codes.contains("4490"),
-                    crs.getName(), hsqlCrs.getName());
+
+            // 3. 检查支持的编码列表
+            Set<String> codes = CRS.getSupportedCodes("EPSG");
+            boolean has4490 = codes.contains("4490");
+
+            log.info("GeoTools EPSG运行时检查通过:factoryAvailable={}, has4490={}, crs={}",
+                    available, has4490, crs.getName());
+
         } catch (Exception e) {
         } catch (Exception e) {
-            log.error("GeoTools EPSG:4490运行时检查失败,请确认运行包包含gt-epsg-hsql、hsqldb,且没有通过loader.path或外部lib混入其他版本GeoTools依赖", e);
+            // 降级为 WARN,不阻断启动 —— CRS 在真正用到时会再次惰性尝试
+            log.warn("GeoTools EPSG:4490运行时检查失败,请确认运行包包含gt-epsg-hsql、hsqldb," +
+                    "且Temp目录无残留锁文件。应用将继续启动,CRS将在使用时惰性重试。错误:{}", e.getMessage());
         }
         }
     }
     }
+
+
+
 }
 }