【问题标题】:cannot find symbol @Activate Error in OSGI class compilation在 OSGI 类编译中找不到符号 @Activate 错误
【发布时间】:2017-07-29 16:46:45
【问题描述】:

我正在尝试编写一个 OSGI 类,它应该填充 Felix 控制台中的配置对话框,我的服务实现如下所示。但是当我尝试运行mvn clean install -PautoInstallPackage 时出现以下错误。任何帮助表示赞赏。

[ERROR] 未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (默认编译)项目 osgiexample.core:编译失败

[错误] /E://osgiexample/core/src/main/java/osgiexample/core/serviceimpl/TestServiceImpl.java:[40,10] 找不到符号

[ERROR] 符号:类激活

[错误] 位置: 类 osgiexample.core.serviceimpl.TestServiceImpl

@Component(immediate=true, label="TEST Service", description="Hello There - This is a Service component", metatype=true)
@Service(value=TestService.class)

public class TestServiceImpl implements TestService {

@Property(value="http://testservice/myservice?wsdl")
static final String SERVICE_ENDPOINT_URL = "service.endpoint.url";

private String serviceEndpointUrl;

    @Override
    public String getData() {
        // TODO Auto-generated method stub
        return null;
    }

    @Activate
    public void activate(final Map<String, Object> props) {
    System.out.println("Calling Activate Method");
    this.serviceEndpointUrl = (String)props.get(SERVICE_ENDPOINT_URL);
    System.out.println("ServiceEndpointUrl:" + this.serviceEndpointUrl);
}
}

【问题讨论】:

  • 您的代码无法编译。看起来您缺少 Activate 注释的导入。
  • @Krish 你的班级有import org.apache.felix.scr.annotations.Activate; 吗?
  • @VAr & toniedzwiedz 错过了导入,感谢您的指点。它解决了我的编译问题。

标签: osgi aem apache-felix osgi-bundle


【解决方案1】:

在下方添加激活注释导入语句应该可以解决您的问题

导入 org.apache.felix.scr.annotations.Activate;

【讨论】:

    猜你喜欢
    • 2011-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-01
    • 2015-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多