diff --git a/common/src/main/java/com/jeesite/common/io/PropertyLoader.java b/common/src/main/java/com/jeesite/common/io/PropertyLoader.java index b6ed453d..c757d0e8 100644 --- a/common/src/main/java/com/jeesite/common/io/PropertyLoader.java +++ b/common/src/main/java/com/jeesite/common/io/PropertyLoader.java @@ -9,31 +9,40 @@ import java.util.List; import java.util.Properties; import org.springframework.boot.env.OriginTrackedMapPropertySource; +import org.springframework.core.Ordered; import org.springframework.core.env.PropertySource; import org.springframework.core.io.Resource; +import com.alibaba.fastjson.parser.ParserConfig; + /** * 配置文件加载(Boot) * @author ThinkGem * @version 2018-10-16 */ -public class PropertyLoader implements org.springframework.boot.env.PropertySourceLoader{ +public class PropertyLoader implements org.springframework.boot.env.PropertySourceLoader, Ordered{ private static boolean isLoadPropertySource = false; @Override public String[] getFileExtensions() { - return new String[] { "properties", "yml" }; + return new String[] { "properties", "yml", "yaml" }; } @Override public List> load(String name, Resource resource) throws IOException { if (!isLoadPropertySource){ isLoadPropertySource = true; + ParserConfig.getGlobalInstance().setSafeMode(true); // 开启 FastJSON 安全模式 Properties properties = PropertiesUtils.getInstance().getProperties(); return Collections.singletonList(new OriginTrackedMapPropertySource("jeesite", properties)); } return Collections.emptyList(); } + + @Override + public int getOrder() { + return Integer.MIN_VALUE; + } } diff --git a/common/src/main/resources/META-INF/spring.factories b/common/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..e3abe452 --- /dev/null +++ b/common/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# PropertySource Loaders +org.springframework.boot.env.PropertySourceLoader=\ +com.jeesite.common.io.PropertyLoader