feat: mybatis-flex-processor 读取 mybatis-flex.properties 添加兜底策略

This commit is contained in:
XiaoLin 2023-06-23 22:16:26 +08:00
parent 0149830eed
commit abb6f6d9a7

View File

@ -16,6 +16,8 @@
package com.mybatisflex.processor.config;
import com.mybatisflex.processor.util.FileUtil;
import javax.annotation.processing.Filer;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
@ -67,6 +69,15 @@ public class MybatisFlexConfig {
inputStream = Files.newInputStream(propertiesFile.toPath());
}
// 兜底如果还是没找到就找项目根目录下的 mybatis-flex.properties
if (inputStream == null) {
final String projectRootPath = FileUtil.getProjectRootPath(propertiesFileObject.toUri().getPath());
final File filePath = new File(projectRootPath, MYBATIS_FLEX);
if (filePath.exists()) {
inputStream = Files.newInputStream(filePath.toPath());
}
}
if (inputStream != null) {
try (InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
properties.load(reader);