使用@Reference获取服务导致maven构建警告
Using @Reference to acquire service results in maven build warning
我正在探索使用 OSGi R6 来声明 OSGi 组件和服务。
要获取服务实例,我们通常会使用@Reference,如下所示:
@Reference
PicklistService picklistService;
从 R5 到 R6 的更改看起来微不足道——我只是将导入语句从 org.apache.felix.scr.annotations.Reference
切换到 org.osgi.service.component.annotations.Reference
。
唯一的问题是在 maven 构建过程中,它会发出警告:
[WARNING] Javadoc Warnings
[WARNING] C:\myapp\core\src\main\java\com\app\service\ServiceImpl.java:50: error: annotation type not applicable to this kind of declaration
[WARNING] @Reference
[WARNING] ^
尽管该功能有效,这意味着我正在获得对我需要的服务的引用。我可以忍受。但我们当然希望尽量减少此类警告。有什么想法吗?
您确定您使用的是 OSGi compendium spec jar 版本 6 吗?
在版本 5 中,您只能在 R6 中的方法上使用 @Reference,它也允许在字段上使用。
我正在探索使用 OSGi R6 来声明 OSGi 组件和服务。 要获取服务实例,我们通常会使用@Reference,如下所示:
@Reference
PicklistService picklistService;
从 R5 到 R6 的更改看起来微不足道——我只是将导入语句从 org.apache.felix.scr.annotations.Reference
切换到 org.osgi.service.component.annotations.Reference
。
唯一的问题是在 maven 构建过程中,它会发出警告:
[WARNING] Javadoc Warnings
[WARNING] C:\myapp\core\src\main\java\com\app\service\ServiceImpl.java:50: error: annotation type not applicable to this kind of declaration
[WARNING] @Reference
[WARNING] ^
尽管该功能有效,这意味着我正在获得对我需要的服务的引用。我可以忍受。但我们当然希望尽量减少此类警告。有什么想法吗?
您确定您使用的是 OSGi compendium spec jar 版本 6 吗? 在版本 5 中,您只能在 R6 中的方法上使用 @Reference,它也允许在字段上使用。