mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 17:48:25 +08:00
!92 mybatis-flex-processor 读取 mybatis-flex.properties 添加兜底从项目根下读取
Merge pull request !92 from Saoforest/main
This commit is contained in:
commit
7aa4857ed3
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.mybatisflex.processor.config;
|
package com.mybatisflex.processor.config;
|
||||||
|
|
||||||
|
import com.mybatisflex.processor.util.FileUtil;
|
||||||
|
|
||||||
import javax.annotation.processing.Filer;
|
import javax.annotation.processing.Filer;
|
||||||
import javax.tools.FileObject;
|
import javax.tools.FileObject;
|
||||||
import javax.tools.StandardLocation;
|
import javax.tools.StandardLocation;
|
||||||
@ -67,6 +69,15 @@ public class MybatisFlexConfig {
|
|||||||
inputStream = Files.newInputStream(propertiesFile.toPath());
|
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) {
|
if (inputStream != null) {
|
||||||
try (InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
|
try (InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
|
||||||
properties.load(reader);
|
properties.load(reader);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user