-1
我想写一个OSGI类,它应该在Felix控制台中填充配置对话框,我的服务实现如下所示。但是当我尝试运行mvn clean install -PautoInstallPackage
时出现以下错误。任何帮助表示赞赏。找不到符号@Activate OSGI类编译错误
[ERROR]未能执行目标 org.apache.maven.plugins:行家-编译器插件:3.2:项目osgiexample.core编译 (默认编译):编制失败
[ ERROR] /E://osgiexample/core/src/main/java/osgiexample/core/serviceimpl/TestServiceImpl.java:[40,10] 找不到符号
[错误]符号:类激活
[错误]位置: 类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”注解的导入。 – toniedzwiedz
@Krish你的课有'import org.apache.felix.scr.annotations.Activate'吗? – VAr
@VAr&toniedzwiedz错过了导入感谢指针。它解决了我的编译问题。 – krish