HA

Spring开发memo

解密Jasypt密文

开发中遇到一些配置的密文,有解密的需要

AES256TextEncryptor encryptor = new AES256TextEncryptor();
encryptor.setPassword("some_salt");
String plainText = encryptor.decrypt(myEncryptedText);
System.out.println("Decrypted: "+plainText);

winmerge 除外特定文件或文件夹

进入 Tools | Filters… | Filefilters选项,编辑Exclude Source Control(也可以新建,但是编辑这个更方便,内置filter可以除外掉版本管理文件)

## Ignore Java class and jar files
f: \.class$
f: \.jar$

## Ignore target directories
d: \\target$

maven运行时出现警告: An illegal reflective access operation has occurred

wget https://www.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp
sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
sudo update-alternatives --install /usr/bin/mvn mvn /opt/apache-maven-3.6.3/bin/mvn 363
sudo update-alternatives --config mvn

手动调用spring组数据校验

    // 定义SmartValidator
    @Bean
    @Primary
    public Validator myValidator() {
      return new LocalValidatorFactoryBean();
    }

    // 使用的时候注入SmartValidator, validationHints可以指定group
    smartValidator.validate(target, errors, validationHints);

// 默认校验只能单层, 如果自定义对象成员变量时, 就需要给成员变量加@Valid, 才能校验自定义对象里的内容

并发控制

// 1. 定义HttpSessionEventPublisher
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
    return new HttpSessionEventPublisher();
}
// 2. 设置maximumSessions
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) {
    http
        .sessionManagement(session -> session
            .maximumSessions(1)
        );
    return http.build();
}

导出svn patch

Show Log -> Show differences as unified diff -> copy + save to file

reference

  1. Decrypt using Jasypt
  2. How to ignore SVN folders in WinMerge
  3. maven: An illegal reflective access operation has occurred
  4. Grouping Javax Validation Constraints | Baeldung
  5. Multiple ‘org.springframework.validation.Validator’ beans are exposed as of Spring Boot 1.5 · Issue #8495 · spring-projects/spring-boot
  6. java - Validation of a list of objects in Spring - Stack Overflow
  7. java - How to manually trigger Spring validation? - Stack Overflow
  8. java - What type of exception to throw in Spring RestController when validation fails? - Stack Overflow
  9. Spring Security Session管理 - 黄建东 - 博客园
  10. Session Management - Spring Security Reference
  11. Spring: Expiring all sessions of a user | Mert Yürtbilir
  12. diff - SVN create patch from committed code? - Stack Overflow
  13. svn - How to use TortoiseSVN via command line? - Stack Overflow