From 8a5623cdddbd6b3e1d90dd6f41bea4730f1f94f0 Mon Sep 17 00:00:00 2001 From: CorvusYe Date: Sun, 28 Jul 2024 17:49:57 +0800 Subject: [PATCH] fix: allow normal startup without any mapper files. --- CHANGELOG.md | 1 + .../org/nebula/contrib/ngbatis/io/MapperResourceLoader.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9fe6e5..cce0a48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ This source code is licensed under Apache 2.0 License. - fix: when `use-session-pool` and spaceFromParam is true, skip the space addition. - fix: when timezone is not default, the time is incorrect. +- fix: allow normal startup without any mapper files. ## Feature diff --git a/src/main/java/org/nebula/contrib/ngbatis/io/MapperResourceLoader.java b/src/main/java/org/nebula/contrib/ngbatis/io/MapperResourceLoader.java index 1459586..4def6ef 100644 --- a/src/main/java/org/nebula/contrib/ngbatis/io/MapperResourceLoader.java +++ b/src/main/java/org/nebula/contrib/ngbatis/io/MapperResourceLoader.java @@ -11,6 +11,7 @@ import static org.nebula.contrib.ngbatis.utils.ReflectUtil.NEED_SEALING_TYPES; import static org.nebula.contrib.ngbatis.utils.ReflectUtil.getNameUniqueMethod; +import java.io.FileNotFoundException; import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; @@ -79,11 +80,14 @@ public MapperResourceLoader(ParseCfgProps parseConfig) { @TimeLog(name = "xml-load", explain = "mappers xml load completed : {} ms") public Map load() { Map resultClassModel = new HashMap<>(); + String mapperLocations = parseConfig.getMapperLocations(); try { - Resource[] resources = getResources(parseConfig.getMapperLocations()); + Resource[] resources = getResources(mapperLocations); for (Resource resource : resources) { resultClassModel.putAll(parseClassModel(resource)); } + } catch (FileNotFoundException ffe) { + log.warn("No mapper files were found in path pattern '{}', please add", mapperLocations); } catch (IOException | NoSuchMethodException e) { throw new ResourceLoadException(e); }