[英]What maven dependencies are needed to get service in non osgi project?
I have a maven nononosgi project witch need to get a service from an osgi project. 我有一个行家nononosgi项目,女巫需要从osgi项目获得服务。 Here is my code: 这是我的代码:
BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
ServiceReference serviceReference = context.getServiceReference(MyClass.class.getName());
MyClass blah = (MyClass) new ServiceTracker(context, serviceReference, null).getService();
blah.doStuff();
This ofcourse doesn't work because a lot of classes aren't imported. 当然这是行不通的,因为没有导入很多类。 What dependencies do i need for the code to work? 我需要什么依赖性代码才能工作?
You can search dependencies at http://search.maven.org based on class names (advanced search). 您可以根据类名称在http://search.maven.org上搜索依赖项(高级搜索)。
You need org.osgi:org.osgi.core and org.osgi:org.osgi.compendium. 您需要org.osgi:org.osgi.core和org.osgi:org.osgi.compendium。 Give the "provided" scope for both of them. 为其提供“提供的”范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.