In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "springboot @ PostConstruct invalid how to solve", interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to solve the problem of "springboot @ PostConstruct invalid".
Springboot @ PostConstruct is invalid
Springboot 1.5.18,jdk9
The @ PostConstruct method is not executed because jdk above jdk8 uses the new module system and javax.annotation is not visible by default.
Solution.
1. Use jdk1.8
two。 Use springboot 2.x
3.POM add javax.annotation:javax.annotation-api dependency
The trample of spring @ PostConstruct has a problem during the startup of the springboot program.
There is a method in the code that needs to be executed after the spring container starts.
So use @ POstConstrut to annotate the method, the local IDE startup is working normally, during deployment using jenkins, a class that implements ApplicationContextAware with SpringContentHondler has a static method to get the bean in the spring container.
After startup, the calling method found that the application variable in SpringContentHondler was not assigned to NULL and reported a null pointer.
The suspicious point is that the local startup is normal, and there is a problem with jenkins startup.
Later, we use the commandrunLister interface provided in spring boot.
After the spring container bean is assembled and initialized, he will call our custom method (you can use @ auto injection normally) so that you can't make a mistake.
At this point, I believe you have a deeper understanding of "springboot @ PostConstruct invalid how to solve", might as well come to the actual operation! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.