common 新增 PropertyLoader 在 Boot 环境初始化属性用
This commit is contained in:
@@ -258,11 +258,17 @@
|
|||||||
<!-- Spring begin -->
|
<!-- Spring begin -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-beans</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-web</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Spring end -->
|
<!-- Spring end -->
|
||||||
|
|
||||||
|
|||||||
@@ -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<PropertySource<?>> 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 在线API文档 -->
|
<!-- 在线文档 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jeesite</groupId>
|
<groupId>com.jeesite</groupId>
|
||||||
<artifactId>jeesite-module-swagger</artifactId>
|
<artifactId>jeesite-module-swagger</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user