`
dannyhz
  • 浏览: 371651 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

springboot yml里面放属性值 由属性类 得到值

 
阅读更多
引用


springboot 放入属性值后

取到值

@Component
public class JwtFilter
   extends OncePerRequestFilter
{
  // private static final Logger log = LogManager.getLogger(JwtFilter.class);
   @Autowired
   private SecurityProperties properties;
  
   protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
     throws ServletException, IOException
   {
     boolean verfiy = true;
     for (String item : this.properties.getIgnoreurl()) {
       if (WebUtils.resolutionUrl(request.getRequestURI(), request.getContextPath()).indexOf(item) == 0) {
         verfiy = false;
       }
     }












引用


application.yml


spring:
  profiles:
    active: dev #正在运行的环境



application-dev.yml


sweeter:
  security:
    ignoreurl[0]: public
    ignoreurl[1]: verifycode
    jwt-exp-millis: 1000000
    jwt-secret: 86df7fc3a34e26a61c034






 package com.zyd.orders.placeorder.cache;
 
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
 @Component
 @ConfigurationProperties("sweeter.security")
 public class SecurityProperties
 {
   private String[] ignoreurl;
   private Long jwtExpMillis;
   private String jwtSecret;
   
   public void setJwtExpMillis(Long jwtExpMillis)
   {
     this.jwtExpMillis = jwtExpMillis;
   }
   
   public void setJwtSecret(String jwtSecret)
   {
     this.jwtSecret = jwtSecret;
   }
   
   public void setIgnoreurl(String[] ignoreurl)
   {
     this.ignoreurl = ignoreurl;
   }
   
   public String[] getIgnoreurl()
   {
     return this.ignoreurl;
   }
   
   public Long getJwtExpMillis()
   {
     return this.jwtExpMillis;
   }
   
   public String getJwtSecret()
   {
     return this.jwtSecret;
   }
 }




分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics