随笔分类 - java
摘要:参考资料: https://www.cnblogs.com/ibigboy/p/11124524.html
阅读全文
摘要:背景: 在一般情况下,我们是使用toString()方法打印信息,但是这种方法并不通用,因此,我们需要一种简单,通用的方法,这里就用到了Gson <!-- gson 开始 --> <dependency> <groupId>com.google.code.gson</groupId> <artifa
阅读全文
摘要:在pom.xml里添加如下依赖: <!-- flyway 开始 --> <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId> </dependency> <!-- flyway 结束 -->
阅读全文
摘要:也可以使用session自带的id,这里演示的是使用自定义uuid为session生成的id @RequestMapping(value = "/uuid", method = RequestMethod.GET) public @ResponseBody String uid(HttpSessio
阅读全文
摘要:背景: 如果不把session存储到redis里,而是采用传统的方式,在前后端分离的项目中,会出现获取不到session的情况 String verificationCodeIn = (String) httpServletRequest.getSession().getAttribute(veri
阅读全文
摘要:假设要匹配的密文: A$2a$10$Cih2shiBNg5jWrj0i.2hbuzZ5.g9T6caaxNP4yYtp3.wpi48rXomu 代码如下: Pattern BCRYPT_PATTERN = Pattern .compile("\\A\\$2a?\\$"); // A$2a$10$Ci
阅读全文
摘要:背景: spring boot 2.1.0 集成 kafka,报错:[org.springframework.kafka.annotation.KafkaListenerAnnotationBeanPostProcessor]: Constructor threw exception; nested
阅读全文
摘要:@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 60) 这个注解添加到启动类上,则session的过期时间为60秒 参考资料: https://docs.spring.io/spring-session/reference/guides/
阅读全文
摘要:<!-- redis --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <version>2.1.0.RELEASE
阅读全文
摘要:<!-- spring session --> <dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session-data-redis</artifactId> </dependency>
阅读全文
摘要:一、引入kafka依赖: <!-- kafka 依赖 开始 --> <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency> <depen
阅读全文
摘要:背景: 如果要使用@ApiOperation注解,需要引入swagger,而不是引入OpenAPI。 在父工程的pom.xml里添加swagger的依赖: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagg
阅读全文
摘要:如果是父子模块,可以把下面的配置添加到父模块的pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</
阅读全文
摘要:在父项目的pom.xml里添加如下依赖: <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-ui</artifactId> <version>1.6.4</version> </dependency
阅读全文
摘要:1.接口的默认方法 在接口中新增了default方法和static方法,这两种方法可以有方法体 2.Lambda 表达式 Lambda表达式可以看成是匿名内部类,使用Lambda表达式时,接口必须是函数式接口 3.函数式接口 如果一个接口只有一个抽象方法,则该接口称之为函数式接口,因为 默认方法 不
阅读全文
摘要:背景: 父模块的pom.xml引入jwt的依赖,如下: <!-- jwt --> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> <version>0.11.1</version> <
阅读全文
摘要:第一步:在我们自定义的LoginService里,使用@Resource注入一个AuthenticationManager @Resource private AuthenticationManager authenticationManager; 注入AuthenticationManager以后
阅读全文
摘要:背景: 首先,要说明的是,无论PHP还是Java,使用bcrypt进行hash得到的密文字符串长度都是60,其中密文的前4位,称为salt // php版是 $2y$10$Cih2shiBNg5jWrj0i.2hbuzZ5.g9T6caaxNP4yYtp3.wpi48rXomu // java版是
阅读全文
摘要:有两种实现方式 一、在application.yml添加如下配置 mybatis-plus: # config-location: classpath:mybatis/mybatis-config.xml mapper-locations: classpath*:mybatis/mapper/**/
阅读全文
摘要:主启动类所在模块的pom.xml,添加junit依赖,如下: <!-- springboot的测试框架,里面有对junit4的依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot
阅读全文