!34 processor 读取 mybatis-flex.properties 文件添加使用 ClassLoader 读取

Merge pull request !34 from Saoforest/main
This commit is contained in:
Michael Yang 2023-05-16 23:04:01 +00:00 committed by Gitee
commit e15de1ac9f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -25,8 +25,8 @@ import java.util.Properties;
class MyBatisFlexProps { class MyBatisFlexProps {
protected Properties properties = new Properties();
private static final String DEFAULT_ENCODING = "UTF-8"; private static final String DEFAULT_ENCODING = "UTF-8";
protected Properties properties = new Properties();
public MyBatisFlexProps(Filer filer) { public MyBatisFlexProps(Filer filer) {
InputStream inputStream = null; InputStream inputStream = null;
@ -37,6 +37,8 @@ class MyBatisFlexProps {
File propertiesFile = new File(propertiesFileObject.toUri()); File propertiesFile = new File(propertiesFileObject.toUri());
if (propertiesFile.exists()) { if (propertiesFile.exists()) {
inputStream = propertiesFileObject.openInputStream(); inputStream = propertiesFileObject.openInputStream();
} else if (getClass().getClassLoader().getResource("mybatis-flex.properties") != null) {
inputStream = getClass().getClassLoader().getResourceAsStream("mybatis-flex.properties");
} else { } else {
File pomXmlFile = new File(propertiesFile.getParentFile().getParentFile().getParentFile(), "pom.xml"); File pomXmlFile = new File(propertiesFile.getParentFile().getParentFile().getParentFile(), "pom.xml");
if (pomXmlFile.exists()) { if (pomXmlFile.exists()) {