Use of Spring Timer QuartzJobBean (work class inherits QuartzJobBean)
1. Introduction to the use of QuartzJobBean:
Timer functions are often used in project development, such as batching in the evening, processing accounts regularly, etc. jdk also provides Timer to implement timer tasks, a brief introduction to Timer implementation.The use of Timer is roughly divided into two steps:
First, write a task class th ...
Posted by cirene on Fri, 10 Apr 2020 20:55:11 -0700
Spring boot exception handling
Spring boot exception handling, usually in two ways
One is to use @ ControllerAdvice
The other is to use ErrorController, the default error handling BasicErrorController of springboot, which is the implemented interface
The first one is called adding interceptor. It's not good. The second one is less error information. It's also bad. It miss ...
Posted by JBS103 on Fri, 10 Apr 2020 08:25:40 -0700
Imitating the function of spring AOP, we use annotations to build our own framework.
I have been in JAVA pit for more than July, and I also try to build a framework by myself. Recently, I am fascinated by this aspect of spring aop, so I record my current small demo, and I will continue to improve my demo later. I hope that the great gods will not be stingy to teach me.
It mainly uses reflection and java's own proxy class. Theor ...
Posted by ksandom on Fri, 10 Apr 2020 07:46:31 -0700
In those years, we stepped on the Java pit
Preface
There is an old saying in China that "nothing is more than three times". It means that a person who has made the same mistake can be forgiven twice and three times at a time, and can't be forgiven more than three times. It has been pointed out that this "three" is an imaginary number, which is used to refer to many t ...
Posted by Grunt on Thu, 09 Apr 2020 23:44:14 -0700
From Java annotation introduction to mastery, this article is enough
Reading this article suggests looking at the table of contents first to grasp the overall context. It's better to have used or customized annotations. Even if you haven't used annotations, the examples in this article must be typed by yourself. This article will take you a step further to uncover the true face of annotations. If you don't un ...
Posted by bfuzze_98 on Wed, 08 Apr 2020 07:21:34 -0700
Spring Cache defect, I seem to have a solution
Spring Cache defect
Spring Cache is a very good cache component.
But in the process of using Spring Cache, Xiao Hei also encountered some pain points.
For example, now there is a requirement: obtain user information in batches through multiple userids.
Option 1
At this point, our code may be as follows:
List<User> users = ids.strea ...
Posted by dfownz on Wed, 08 Apr 2020 04:56:35 -0700
spring - use profile to manage environment information
Programs generally have development environment, test environment and online environment. The basis of program running in these environments is generally different. For example, in a program with data source access, embedded database may be used in development, and independent mysql may be used in the test environment. After the program is offi ...
Posted by nttaylor on Tue, 07 Apr 2020 22:17:24 -0700
How does Spring solve circular dependency? Do you really understand?
Guide reading
Articles published the other day Spring boot multi data source dynamic switch and Spring boot: a huge pit for integrating multiple data sources In, it is mentioned that adding @ Primary interface to dynamic data source will cause circular dependency exception, as shown in the following figure:
This is a typical constructor dep ...
Posted by MHardeman25 on Tue, 07 Apr 2020 05:54:02 -0700
One of BeanPostProcessors in spring: InstantiationAwareBeanPostProcessor (01)
beanPostProcessor is an absolute pioneering product in spring, giving programmers a lot of autonomy. beanPostProcessor is often referred to as the bean postprocessor.
1. Overview
Let's start with InstantiationAwareBeanPostProcessor, which is a subinterface of BeanPostProcessor and inherits from BeanPostProcessor. Let's look at the methods in ...
Posted by Quest on Sun, 05 Apr 2020 21:54:09 -0700
Design Mode-Proxy Mode JAVA Implementation
The proxy model is simply a design pattern for pre- and post-intervention on Methods in existing classes to modify an existing business at the class or method level without modifying an existing business class.
There are currently two implementations, one is a static proxy, implemented purely through code based on design patterns.The other is ...
Posted by mwasif on Sun, 05 Apr 2020 20:15:41 -0700