Home
  • 计算机网络
  • 操作系统
  • 数据结构与算法
  • 设计模式
  • JavaSE
  • JVM
  • JUC
  • Netty
  • CPP
  • QT
  • UE
  • Go
  • Gin
  • Gorm
  • HTML
  • CSS
  • JavaScript
  • vue2
  • TypeScript
  • vue3
  • react
  • Spring
  • SpringMVC
  • Mybatis
  • SpringBoot
  • SpringSecurity
  • SpringCloud
  • Mysql
  • Redis
  • 消息中间件
  • RPC
  • 分布式锁
  • 分布式事务
  • 个人博客
  • 弹幕视频平台
  • API网关
  • 售票系统
  • 消息推送平台
  • SaaS短链接系统
  • Linux
  • Docker
  • Git
GitHub (opens new window)
Home
  • 计算机网络
  • 操作系统
  • 数据结构与算法
  • 设计模式
  • JavaSE
  • JVM
  • JUC
  • Netty
  • CPP
  • QT
  • UE
  • Go
  • Gin
  • Gorm
  • HTML
  • CSS
  • JavaScript
  • vue2
  • TypeScript
  • vue3
  • react
  • Spring
  • SpringMVC
  • Mybatis
  • SpringBoot
  • SpringSecurity
  • SpringCloud
  • Mysql
  • Redis
  • 消息中间件
  • RPC
  • 分布式锁
  • 分布式事务
  • 个人博客
  • 弹幕视频平台
  • API网关
  • 售票系统
  • 消息推送平台
  • SaaS短链接系统
  • Linux
  • Docker
  • Git
GitHub (opens new window)
  • 如何设计一个短链系统
  • 新Get的开发技巧
    • @RequiredArgsConstructor注解实现自动注入
    • hutool工具类
    • dev与prod开发环境
  • 项目通用工具

  • 用户模块

  • 短链模块

  • 流量风控
  • 如何获取用户IP?
  • SaaS短链接系统
Nreal
2024-01-05
目录

新Get的开发技巧

# @RequiredArgsConstructor注解实现自动注入

lombok提供

使用@RequiredArgsConstructor代替@Autowired实现对象属性的自动注入;

优点:省略很多@Autowired注解;

注意:注入时需要使用final定义;

@RestController
@RequiredArgsConstructor // lombok构造器注入
public class UserController {

    private final UserService userService;
    
    // ...
        
}
1
2
3
4
5
6
7
8
9

# hutool工具类

Str.isAllNotBlank性能比Str.isAllNotEmpty差,但是后者概括不了全部;

# dev与prod开发环境

yml文件中:

spring:
  datasource:
    driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
    url: jdbc:shardingsphere:classpath:shardingsphere-config-${database.env:dev}.yaml
1
2
3
4

默认启动dev配置文件;

如果需要使用prod配置文件:

启动配置添加VM参数:

如何设计一个短链系统
异常设计

← 如何设计一个短链系统 异常设计→

Theme by Vdoing | Copyright © 2021-2024
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式