spring
lx6766
这个作者很懒,什么都没留下…
展开
-
除了用if else来对流程是否继续执行做判断,还可以用Assert
import org.springframework.util.Assert;Assert.isNull(88, "非空就抛出异常吧!");IllegalArgumentException: 非空就抛出异常吧!这种方式比if ,else的写法更简洁,可读性也更好,我喜欢!...原创 2020-03-22 14:02:09 · 940 阅读 · 0 评论 -
关于spring的条件注解的使用@Conditionxxx
1 condition注解的基本使用,不论是由spring实现的还是自定义的,首先要了解的就是它的实现原理,这就要从自定义一个注解开始第一步,先了解注解可以用在哪些地方,看元注解 @interface2 @ConditionalOnExpression 表达式值决定是否执行变量表达式的key取自属性配置文件数值型和布尔型@ConditionalOnExpression("${s...原创 2020-03-05 14:22:43 · 1596 阅读 · 0 评论 -
关于spring 定时@schedule注解的使用
1定时方法所在类,必须有@Component注解,即被spring容器所管理才可以被识别@Slf4j@Component@Asyncpublic class DailyPlayCountSchedule { @Scheduled(cron = "28 * * * * ?")// @SchedulerLock(name = "dataHouseKeepingLock", lockA...原创 2019-11-27 14:09:46 · 3228 阅读 · 0 评论 -
关于AOP切面日志在写的时候要注意的几点
1配置类,最基本的就是要加上注解@Aspect2关于在哪里起作用,通过注解或方法名均可@Around("@within(org.springframework.stereotype.Controller) || @annotation(org.springframework.stereotype.Controller)")public Object apiLog(Proceeding...原创 2019-11-13 11:51:18 · 598 阅读 · 0 评论 -
sprintboot 前前后后
之前:之后:关系:spring生成方式:1在官网上提供了网页,直接生成初始化项目:原创 2019-07-04 15:45:48 · 130 阅读 · 0 评论 -
spring boot生成一个web项目
1使用idea生成一个web项目2等待maven下载依赖3 mvn:compile编译4找到注有@SpringBootApplication的类,执行run ,就普通main方法那样即可上面是一种启动方式,还可以在命令行mvn spring-boot:run ,获取mvn install,获得jar文件后 java -jar xx.jar(web项目也一样可以是jar)注意:j...原创 2019-07-03 16:09:58 · 765 阅读 · 0 评论 -
spring的applicatonContext不需要手动销毁
世上本无事,庸人自扰之。明明是他人之错,确偏偏要在自己身上找原因,头疼两三天。原场景:同时加载了CloudUtil和AppliationContext对象,程序执行完毕后,并未退出。下意识的把util类排除在外,没想过要手动关闭,一心将问题定位在Spring ApplicationContext上,悲哉!原创 2019-06-18 13:54:56 · 810 阅读 · 0 评论