简体   繁体   English

Spring注解和生命周期。

[英]Spring annotation and lifecycle.

I have 2 questions specific to Spring. 我有2个关于Spring的问题。

  1. Does @Component, @Service have to be on the implementation or interface ? @ Component,@ Service是否必须在实现或接口上? And which one is the preferred method ? 哪一种是首选方法?

  2. If there is an external configuration class I have for eg ApplicationConfiguration. 如果有一个外部配置类,例如ApplicationConfiguration。 How do I hook this class into the Spring lifecycle ? 如何将此类与Spring生命周期挂钩? What is the point I should look for ? 我应该寻找什么?

  1. It should be on the implementation. 应该在执行上。
  2. You should have text .properties file for your configuration. 您应该具有用于​​配置的文本.properties文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 @PostConstruct 注释和 spring 生命周期 - @PostConstruct annotation and spring lifecycle 活动生命周期。 用户始终离线 - Activity lifecycle. User always offline JSF生命周期。 使用panelGrid来嵌套组件(使用ui:include) - JSF lifecycle. Using panelGrid for nested component (with ui:include) Junit5 参数化测试生命周期。 为什么 @BeforeAll 和 static 块在所有测试之后运行 - Junit5 Parameterized Test LifeCycle. why @BeforeAll and static block run after all the tests Spring生命周期问题:@SessionAttributes注释使会话属性的生存期比会话本身更长 - Spring lifecycle issue: the annotation @SessionAttributes makes session attributes live longer than the session itself Spring:SmartLifecycle:Lifecycle.stop() 未调用<mvc:annotation-driven />但它与@EnableWebMvc - Spring: SmartLifecycle: Lifecycle.stop() not called with <mvc:annotation-driven /> but it is with @EnableWebMvc 春季事件生命周期 - Spring event lifecycle Spring 引导中的 PersistenceContext 生命周期 - PersistenceContext lifecycle in Spring Boot Spring中Jackson ObjectMapper的生命周期 - Lifecycle of Jackson ObjectMapper in Spring Spring AOP:@annotation(annotation) - Spring AOP: @annotation(annotation)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM