[quote]
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;
}
}
[/quote]
[quote]
application.yml
spring:
profiles:
active: dev #正在运行的环境
application-dev.yml
sweeter:
security:
ignoreurl[0]: public
ignoreurl[1]: verifycode
jwt-exp-millis: 1000000
jwt-secret: 86df7fc3a34e26a61c034
[/quote]
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;
}
}
[/quote]
[quote]
application.yml
spring:
profiles:
active: dev #正在运行的环境
application-dev.yml
sweeter:
security:
ignoreurl[0]: public
ignoreurl[1]: verifycode
jwt-exp-millis: 1000000
jwt-secret: 86df7fc3a34e26a61c034
[/quote]
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;
}
}