Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 Handler 对象,它的功能有点像服务。它在实现中定义了一个公共 init 方法,但在接口中没有。这个处理程序也通过 Spring 自动装配。init 方法是如何被调用的?是通过 Spring 还是 Tomcat 调用它?
如果是春天,一个init-method属性应该可以解决问题。类似地,可以实现调用的InitializingBean#afterPropertiesSet方法。init
init-method
InitializingBean#afterPropertiesSet
init
如果您在 spring 中没有看到init-method为您的 bean 声明指定属性,请default-init-method="init"在根标记中查找属性声明,beans.
default-init-method="init"
beans