SpringBoot中静态类使用配置文件
2023-09-11 14:16:34 时间
SpringBoot中静态类使用配置文件
经常遇到读取为NULL的情况,现在我就告诉大家。
----------------------------------application-jwt.properties------------------------
ccb.jwt.toke.secret=eyJhbGciOiJIUzI1NiJ9
ccb.jwt.toke.issuer=BJxingjingzhida
ccb.jwt.toke.userno=userId
ccb.jwt.toke.date=1
----------------------------------JwtProConfig,java---------------------------------
package com.bcc.common.config;
import javax.annotation.PostConstruct;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
//@Component
@PropertySource({"classpath:application-jwt.properties"})
@ConfigurationProperties(prefix = "ccb.jwt.toke")
public class JwtProConfig {
public static String TOKEN_SECRET;
public static String ISSUER;
public static String USERNO;
public static Long DATE;// = 1L; //10秒钟
public String secret;
public String issuer;
public String userno;
public Long date;
@PostConstruct
public void JwtProConfigValue() {
TOKEN_SECRET = this.secret;
ISSUER = this.issuer;
USERNO = this.userno;
//DATE = Long.valueOf(this.date);
DATE = this.date;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getIssuer() {
return issuer;
}
public void setIssuer(String issuer) {
this.issuer = issuer;
}
public String getUserno() {
return userno;
}
public void setUserno(String userno) {
this.userno = userno;
}
public Long getDate() {
return date;
}
public void setDate(Long date) {
this.date = date;
}
}
----------------------------------最后直 接类.静态属性 -------------------------------
相关文章
- springboot中配置urlrewrite实现url伪静态强化网站seo
- 补习系列(2)-springboot mime类型处理
- springboot 项目maven 打包错误
- intellij idea2021.2:创建一个springboot项目(springboot 2.5.4)
- springboot 文件上传工具类(校验)【魔数值】
- Idea中SpringBoot启动类的那些事
- 【项目实战】Springboot整合SCP,实现远程文件拷贝与传输功能
- 【最全最详细】SpringBoot 中实现跨域的几种方式
- 在springboot中,如何读取配置文件中的属性
- 基于注解SpringAOP,AfterReturning,Before,Around__springboot工程 @Around 简单的使用__SpringBoot:AOP 自定义注解实现日志管理
- SpringBoot操作hbase
- 《Springboot极简教程》使用Spring Boot, JPA, Mysql, ThymeLeaf,gradle, Kotlin快速构建一个CRUD Web App
- springboot拦截器拦了静态资源css,js,png,jpeg,svg等等静态资源
- 005-spring cache-原理、缓存AOP机制、Spring Cache抽象集成机制、springboot自动配置机制
- SpringBoot配置Shiro时@RequiresRoles不起作用
- RabbitMQ---延迟队列,整合springboot
- SpringBoot遗忘知识点整理
- 基于Java+SpringBoot超市管理系统设计与实现