mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
3.0.0
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.gitee.sop.adminserver.config;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.PropertiesPropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 自定义环境处理,在运行SpringApplication之前加载任意配置文件到Environment环境中
|
||||
* https://www.jianshu.com/p/be6c818fe6ff
|
||||
*/
|
||||
public class SopAdminEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
|
||||
private final Properties properties = new Properties();
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
Resource resource = new ClassPathResource("sop-admin.properties");
|
||||
// 加载成PropertySource对象,并添加到Environment环境中
|
||||
environment.getPropertySources().addLast(loadProfiles(resource));
|
||||
}
|
||||
|
||||
private PropertySource<?> loadProfiles(Resource resource) {
|
||||
if (resource == null || !resource.exists()) {
|
||||
throw new IllegalArgumentException("资源" + resource + "不存在");
|
||||
}
|
||||
try {
|
||||
properties.load(resource.getInputStream());
|
||||
return new PropertiesPropertySource(resource.getFilename(), properties);
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException("加载配置文件失败" + resource, ex);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
# 自定义自动配置类,如果有多个类,使用逗号(,)分隔,\正斜杠标示换行还可以读取到指定的类
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=com.gitee.sop.adminserver.config.SopAdminEnvironmentPostProcessor
|
@@ -1,7 +1,5 @@
|
||||
server.port=8082
|
||||
spring.application.name=sop-admin
|
||||
|
||||
# ------- 需要改的配置 -------
|
||||
# mysql数据库账号
|
||||
mysql.host=localhost:3306
|
||||
mysql.username=root
|
||||
@@ -9,33 +7,5 @@ mysql.password=root
|
||||
|
||||
# nacos注册中心地址
|
||||
nacos.url=127.0.0.1:8848
|
||||
# ------- 需要改的配置end -------
|
||||
|
||||
# session过期时间,分钟
|
||||
admin.access-token.timeout-minutes=30
|
||||
# 签名方式,rsa:支付宝开放平台签名方式,md5:淘宝开放平台签名方式
|
||||
sop.sign-type=rsa
|
||||
|
||||
# nacos配置
|
||||
nacos.config.server-addr=${nacos.url}
|
||||
nacos.discovery.server-addr=${nacos.url}
|
||||
|
||||
# 数据库配置
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://${mysql.host}/sop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||
spring.datasource.username=${mysql.username}
|
||||
spring.datasource.password=${mysql.password}
|
||||
|
||||
# 固定不用改
|
||||
mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
|
||||
easyopen.show-doc=false
|
||||
easyopen.ignore-validate=true
|
||||
|
||||
logging.level.com.gitee=debug
|
||||
|
||||
# 不用改
|
||||
mybatis.fill.com.gitee.fastmybatis.core.support.DateFillInsert=gmt_create
|
||||
mybatis.fill.com.gitee.fastmybatis.core.support.DateFillUpdate=gmt_modified
|
||||
|
||||
# 不用改,如果要改,请全局替换修改
|
||||
sop.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC
|
||||
|
@@ -0,0 +1,32 @@
|
||||
# 这里的配置不用改,如果要改在application-xx.properties中改
|
||||
# 在application-xx.properties中配置会覆盖这里的值
|
||||
# 参考:com.gitee.sop.adminserver.config.SopAdminEnvironmentPostProcessor
|
||||
|
||||
spring.application.name=sop-admin
|
||||
|
||||
# session过期时间,分钟
|
||||
admin.access-token.timeout-minutes=30
|
||||
# 签名方式,rsa:支付宝开放平台签名方式,md5:淘宝开放平台签名方式
|
||||
sop.sign-type=rsa
|
||||
|
||||
# nacos配置
|
||||
nacos.config.server-addr=${nacos.url}
|
||||
nacos.discovery.server-addr=${nacos.url}
|
||||
|
||||
# 数据库配置
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://${mysql.host}/sop?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
|
||||
spring.datasource.username=${mysql.username}
|
||||
spring.datasource.password=${mysql.password}
|
||||
|
||||
# 固定不用改
|
||||
mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
|
||||
easyopen.show-doc=false
|
||||
easyopen.ignore-validate=true
|
||||
|
||||
# 不用改
|
||||
mybatis.fill.com.gitee.fastmybatis.core.support.DateFillInsert=gmt_create
|
||||
mybatis.fill.com.gitee.fastmybatis.core.support.DateFillUpdate=gmt_modified
|
||||
|
||||
# 不用改,如果要改,请全局替换修改
|
||||
sop.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC
|
@@ -1,4 +1,4 @@
|
||||
package com.gitee.sop.gatewaycommon.env;
|
||||
package com.gitee.sop.gatewaycommon.config;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
@@ -14,7 +14,7 @@ import java.util.Properties;
|
||||
/**
|
||||
* 自定义环境处理,在运行SpringApplication之前加载任意配置文件到Environment环境中
|
||||
*/
|
||||
public class SopEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
public class SopGatewayEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
|
||||
private final Properties properties = new Properties();
|
||||
|
@@ -1,3 +1,3 @@
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=com.gitee.sop.gatewaycommon.env.SopEnvironmentPostProcessor
|
||||
# 自定义自动配置类,如果有多个类,使用逗号(,)分隔,\正斜杠标示换行还可以读取到指定的类
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=com.gitee.sop.gatewaycommon.config.SopGatewayEnvironmentPostProcessor
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.gitee.sop.bridge.SopGatewayAutoConfiguration
|
||||
|
Reference in New Issue
Block a user