In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
When will full screen mode be used?
© 2024 shulou.com SLNews company. All rights reserved.