@PreDestroy突然失效
@PostConstruct生效,@PreDestroy以前生效,突然无效了。
这里我找到的办法是导入javax.annotation依赖,@PreDestroy就生效了
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</dependency>
注:
我发现不是添加javax.annotation依赖的解决问题,是在idea的debug运行是@PreDestroy是生效的,而在run模式运行@PreDestroy就失效。本人不知道为什么,有大佬知道请在评论指教。