yaml文件,配置正则规则
sy:
log:
regexArray:
- ".*detail.*"
- ".*get.*"
- ".*find.*"
- ".*byid.*"
- ".*byname.*"
类的读取
@Data
@ConfigurationProperties(prefix = "sy.log")
@ConditionalOnProperty(prefix = "sy.log", name = {"enabled"}, havingValue = "true", matchIfMissing = true)//条件
public class LogAutoConfiguration {
private List<String> regexArray;
......
}
正则表达式的简单应用
String methodName = joinPoint.getSignature().getName();
return this.regexArray.stream().anyMatch(regex -> Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(methodName).find());