SpringBoot开发技巧
SpringBoot开发小技巧1. LombokLombok用标签方式代替构造器、getter/setter、toString()等鸡肋代码。 spring boot已经管理Lombok。引入依赖: 1234<dependency> <groupId>org.projectlombok</groupId> <artifact...
SpringBoot开发小技巧1. LombokLombok用标签方式代替构造器、getter/setter、toString()等鸡肋代码。 spring boot已经管理Lombok。引入依赖: 1234<dependency> <groupId>org.projectlombok</groupId> <artifact...
1、拦截器-登录检查与资源放行 编写一个拦截器实现HandlerInterceptor接口 拦截器注册到容器中(实现WebMvcConfigurer的addInterceptors()) 指定拦截规则(注意,如果是拦截所有,静态资源也会被拦截) 编写一个实现HandlerInterceptor接口的拦截器: 12345678910111213141516171819202122232425...
1、单元测试-JUnit5简介Spring Boot 2.2.0 版本开始引入 JUnit 5 作为单元测试默认库 作为最新版本的JUnit框架,JUnit5与之前版本的JUnit框架有很大的不同。由三个不同子项目的几个不同模块组成。 JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage JUnit Platform: ...
1、数据访问-数据库场景的自动配置分析与整合测试导入JDBC场景1234<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jdbc</artifactId></dependenc...
1. @Configuration详解 基本使用 Full模式和Lite模式 示例: 1234567891011121314151617181920212223242526/** * 1、配置类里面使用@Bean标注在方法上给容器注册组件,默认也是单实例的 * 2、配置类本身也是组件 * 3、proxyBeanMethods:代理bean的方法 * Full(proxyBean...
自动包规则原理SpringBoot应用的启动类: 123456@SpringBootApplicationpublic class MainApplication { public static void main(String[] args) { SpringApplication.run(MainApplication.class, args); ...