启动组件时不调用@Activate



按照Liferay关于使模块可配置的文档,我编写了这个Liferay 7模块:

@Component(configurationPid = "myproject.api.TranslationConfiguration")
public class TranslationServiceImpl implements TranslationService {
private volatile TranslationConfiguration configuration;
public TranslationServiceImpl() {
log.info("TranslationServiceImpl constructor");
}
@Activate
@Modified
protected void activate(Map<String, Object> properties) {
log.info("Hello from activate");
}
}

部署时,日志仅显示:

TranslationServiceImpl constructor
Service registered.
STARTED myproject.impl_1.0.0 [538]

为什么不调用activate方法?

在 Gogo Shell 中重新启动模块也不会调用activate

默认情况下,声明性服务中的组件仅在其服务被另一个捆绑包引用时激活。

如果您希望它立即启动,请使用immediate=true

最新更新