在OSGI类编译中找不到符号@Activate Error

在OSGI类编译中找不到符号@Activate Error,osgi,aem,apache-felix,osgi-bundle,Osgi,Aem,Apache Felix,Osgi Bundle,我正在尝试编写一个OSGI类,它应该填充Felix控制台中的配置对话框,我的服务实现如下所示。但是当我尝试运行mvn clean install-PautoInstallPackage时,我得到了以下错误。感谢您的帮助 [错误]无法执行目标 插件:maven编译器插件:3.2:编译 项目osgiexample.core上的(默认编译):编译失败 [错误] /E://osgiexample/core/src/main/java/osgiexample/core/serviceinpl/testse

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

[错误]无法执行目标 插件:maven编译器插件:3.2:编译 项目osgiexample.core上的(默认编译):编译失败

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

[错误]符号:类激活

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

@Component(immediate=true,label=“TEST Service”,description=“你好,这是一个服务组件”,metatype=true)
@服务(值=TestService.class)
公共类TestServiceImpl实现TestService{
@属性(值=”http://testservice/myservice?wsdl")
静态最终字符串SERVICE\u ENDPOINT\u URL=“SERVICE.ENDPOINT.URL”;
私有字符串serviceEndpointUrl;
@凌驾
公共字符串getData(){
//TODO自动生成的方法存根
返回null;
}
@激活
公共无效激活(最终地图道具){
System.out.println(“调用激活方法”);
this.serviceEndpointUrl=(字符串)props.get(SERVICE\u ENDPOINT\u URL);
System.out.println(“ServiceEndpointUrl:+this.ServiceEndpointUrl”);
}
}

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

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


您的代码无法编译。看起来您缺少导入的
Activate
批注。@Krish您的类是否有
import org.apache.felix.scr.annotations.Activate?@VAr&toniedzwiedz错过了导入,感谢指针。它解决了我的编译问题。
@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);
}
}