!92 mybatis-flex-processor 读取 mybatis-flex.properties 添加兜底从项目根下读取

Merge pull request !92 from Saoforest/main
This commit is contained in:
Michael Yang 2023-06-23 14:31:03 +00:00 committed by Gitee
commit 7aa4857ed3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

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);