From c80c5ec7697e325403a0424c672083efc381cded Mon Sep 17 00:00:00 2001 From: thinkgem Date: Tue, 16 Oct 2018 22:07:34 +0800 Subject: [PATCH] =?UTF-8?q?common=20=E6=96=B0=E5=A2=9E=20PropertyLoader=20?= =?UTF-8?q?=E5=9C=A8=20Boot=20=E7=8E=AF=E5=A2=83=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=B1=9E=E6=80=A7=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/pom.xml | 8 +++- .../com/jeesite/common/io/PropertyLoader.java | 39 +++++++++++++++++++ web/pom.xml | 2 +- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/com/jeesite/common/io/PropertyLoader.java diff --git a/common/pom.xml b/common/pom.xml index 3dda0cf2..37875bb7 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -258,11 +258,17 @@ org.springframework - spring-core + spring-beans org.springframework spring-web + true + + + org.springframework.boot + spring-boot + true diff --git a/common/src/main/java/com/jeesite/common/io/PropertyLoader.java b/common/src/main/java/com/jeesite/common/io/PropertyLoader.java new file mode 100644 index 00000000..b6ed453d --- /dev/null +++ b/common/src/main/java/com/jeesite/common/io/PropertyLoader.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2013-Now http://jeesite.com All rights reserved. + */ +package com.jeesite.common.io; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +import org.springframework.boot.env.OriginTrackedMapPropertySource; +import org.springframework.core.env.PropertySource; +import org.springframework.core.io.Resource; + +/** + * 配置文件加载(Boot) + * @author ThinkGem + * @version 2018-10-16 + */ +public class PropertyLoader implements org.springframework.boot.env.PropertySourceLoader{ + + private static boolean isLoadPropertySource = false; + + @Override + public String[] getFileExtensions() { + return new String[] { "properties", "yml" }; + } + + @Override + public List> load(String name, Resource resource) throws IOException { + if (!isLoadPropertySource){ + isLoadPropertySource = true; + Properties properties = PropertiesUtils.getInstance().getProperties(); + return Collections.singletonList(new OriginTrackedMapPropertySource("jeesite", properties)); + } + return Collections.emptyList(); + } + +} diff --git a/web/pom.xml b/web/pom.xml index 43c3e4c9..17c919ef 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -37,7 +37,7 @@ ${project.parent.version} - + com.jeesite jeesite-module-swagger