Merge pull request #7 from weihubeats/add-spring-boot-nebula-all
Add spring boot nebula all
This commit is contained in:
commit
45e09d4e20
|
@ -152,3 +152,8 @@
|
||||||
- [spring-boot-nebula-web-common](spring-boot-nebula-web-common) web模块基础工具类
|
- [spring-boot-nebula-web-common](spring-boot-nebula-web-common) web模块基础工具类
|
||||||
- [spring-boot-nebula-distribute-lock](spring-boot-nebula-distribute-lock) 分布式锁
|
- [spring-boot-nebula-distribute-lock](spring-boot-nebula-distribute-lock) 分布式锁
|
||||||
|
|
||||||
|
## [spring-boot-nebula-web-common](spring-boot-nebula-web-common)
|
||||||
|
- 提供[SpringBeanUtils.java](spring-boot-nebula-web-common%2Fsrc%2Fmain%2Fjava%2Fcom%2Fnebula%2Fweb%2Fcommon%2Futils%2FSpringBeanUtils.java)获取spring bean
|
||||||
|
- 提供[NebulaSysWebUtils.java](spring-boot-nebula-web-common%2Fsrc%2Fmain%2Fjava%2Fcom%2Fnebula%2Fweb%2Fcommon%2Futils%2FNebulaSysWebUtils.java) 获取spring 环境信息
|
||||||
|
- 提供[ExpressionUtil.java](spring-boot-nebula-web-common%2Fsrc%2Fmain%2Fjava%2Fcom%2Fnebula%2Fweb%2Fcommon%2Futils%2FExpressionUtil.java) 解析el表达式
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nebula.web.common.autoconfigure;
|
package com.nebula.web.common.autoconfigure;
|
||||||
|
|
||||||
|
import com.nebula.web.common.utils.NebulaSysWebUtils;
|
||||||
import com.nebula.web.common.utils.SpringBeanUtils;
|
import com.nebula.web.common.utils.SpringBeanUtils;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -10,12 +11,17 @@ import org.springframework.context.annotation.Configuration;
|
||||||
* @description:
|
* @description:
|
||||||
*/
|
*/
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
public class NebulaApplicationContextAware {
|
public class NebulaWebCommonAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SpringBeanUtils springBeanUtils() {
|
public SpringBeanUtils springBeanUtils() {
|
||||||
return new SpringBeanUtils();
|
return new SpringBeanUtils();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public NebulaSysWebUtils nebulaSysWebUtils() {
|
||||||
|
return new NebulaSysWebUtils();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.nebula.web.common.utils;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : wh
|
||||||
|
* @date : 2024/3/21 10:21
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "nebula")
|
||||||
|
@Data
|
||||||
|
public class NebulaSysWebUtils {
|
||||||
|
|
||||||
|
private static final String DEV = "dev";
|
||||||
|
|
||||||
|
private static final String TEST = "test";
|
||||||
|
|
||||||
|
private static final String STAGE = "stage";
|
||||||
|
|
||||||
|
private static final String PRD = "prd";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开发环境
|
||||||
|
*/
|
||||||
|
@Value("${spring.profiles.active:dev}")
|
||||||
|
private String active;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务名
|
||||||
|
*/
|
||||||
|
@Value("${spring.application.name:unknown}")
|
||||||
|
private String applicationName;
|
||||||
|
|
||||||
|
public boolean isDev() {
|
||||||
|
return Objects.equals(active, DEV);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTest() {
|
||||||
|
return Objects.equals(active, TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPrd() {
|
||||||
|
return Objects.equals(active, PRD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStage() {
|
||||||
|
return Objects.equals(active, STAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,2 +1,2 @@
|
||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.nebula.web.common.autoconfigure.NebulaApplicationContextAware
|
com.nebula.web.common.autoconfigure.NebulaWebCommonAutoConfiguration
|
||||||
|
|
Loading…
Reference in New Issue