我有一个maven项目,它的库也应该是一个带有声明性服务的OSGi包。我添加了OSGI-INF文件夹,其中的service.xml在src/java/resources中,它将被添加到jar中。但是:当我作为equinox项目启动项目时,我想检查服务是否已加载,我得到的错误是无法找到OSGI-INF/service.xml。我猜eclipse在启动时不会将资源文件夹添加到类路径中。
顺便说一下: MANIFEST-MF位于根文件夹中,pom.xml包含以下文本:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
有没有一个好主意告诉eclipse在哪里可以找到元数据文件?如果这是相关的,我会使用m2eclipse。
提前感谢Hannes
发布于 2010-11-28 01:51:40
我也有同样的问题,但我已经手动调整了我的POM.xml,以便复制生成目标/classes/META-INF/**内容(MANIFEST.MF、属性文件、spring,...)放入项目根文件夹( Eclipse PDE需要):
<!--
We copy all stuff from target/classes/META-INF into META-INF/ in order
to keep Maven output with PDE.
-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>synch-pde-metadata-from-maven</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/META-INF</outputDirectory>
<resources>
<resource>
<directory>target/classes/META-INF</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!--
We delete all stuff from the root bundle's META-INF
-->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>META-INF</directory>
<includes>
<include>**/*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
(当调用mvn clean时,我也会清理东西)它并不是很有效,但它很有效。
Ps:您可能需要在项目上单击鼠标右键并将其设置为插件项目,才能正常工作。
发布于 2016-09-16 14:16:38
问题是Eclipse需要根目录中的OSGI-INF (以及META-INF)文件夹。
我找到了一个关于如何解决这个问题的链接。https://www.nuxeo.com/blog/working-with-osgi-and-maven-in-eclipse/
基本上,他们将OSGI-INF和META-INF文件夹放在src/main/resources中
然后他们将src/main/resources文件夹设置为OSGI项目的根目录。因此Eclipse在根目录下都有这两个文件夹。为了使源文件也可用,他们通过在.project文件中添加一个条目,在src/ Linked Resources /java中添加了一个主文件
<linkedResources>
<link>
<name>src</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/java</locationURI>
</link>
</linkedResources>
现在,您只需要将.prject和.classpath文件复制到src/main/resources (您的新根目录)中,一切都应该正常了。
在写这篇文章的时候,我还没有自己测试这个,但我会在不久的将来进行测试。
https://stackoverflow.com/questions/3440794
复制相似问题