Is what I want now before I start this class to perform static code block, through the automatic injection of the dao to query the database load data (because I don't want to frequently check, the management said that don't use redis), if direct
The @autowired
Private static HolidayDao HolidayDao;
This way, in the static block of code will be null pointer inside, how to use this dao in static code block to query a data
CodePudding user response:
@ Resource
Private KpzMapper KpzMapper;
Private static KpzMapper tl;
//in a static method call Mapper update database
@ PostConstruct
Public void init () {
Tl=kpzMapper;
}
In the tl to call a method that