2017-03-08 104 views
-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); 
} 
} 
+0

您的代碼不能編譯。看起來你錯過了「Activate」註解的導入。 – toniedzwiedz

+0

@Krish你的課有'import org.apache.felix.scr.annotations.Activate'嗎? – VAr

+0

@VAr&toniedzwiedz錯過了導入感謝指針。它解決了我的編譯問題。 – krish

回答

0

添加下面的註釋激活import語句應該解決您的問題

進口org.apache.felix.scr.annotations.Activate;