Osgi 捆绑包时使用src而不是target

Osgi 捆绑包时使用src而不是target,osgi,osgi-bundle,maven-bundle-plugin,Osgi,Osgi Bundle,Maven Bundle Plugin,当我在我的项目上运行命令“mvn package”时,src/main/resources/META-INF中的persistence.xml、persistence.xml.dev、persistence.xml.qa等资源文件都打包在包中。我需要帮助使mvn bundle插件查看目标文件夹而不是src文件夹,因为我的目标文件夹将只有一个资源文件persistence.xml。下面是我的pom mave bundle插件 <plugin>

当我在我的项目上运行命令“mvn package”时,src/main/resources/META-INF中的persistence.xml、persistence.xml.dev、persistence.xml.qa等资源文件都打包在包中。我需要帮助使mvn bundle插件查看目标文件夹而不是src文件夹,因为我的目标文件夹将只有一个资源文件persistence.xml。下面是我的pom mave bundle插件

<plugin>
                      <groupId>org.apache.felix</groupId>
                      <artifactId>maven-bundle-plugin</artifactId>
                      <extensions>true</extensions>
                      <executions>
                          <execution>
                              <id>bundle</id>
                              <phase>package</phase>
                              <goals>
                                  <goal>bundle</goal>
                              </goals>
                          </execution>
                      </executions>
                      <configuration>
                          <instructions>
                              <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                              <Bundle-Classpath>.</Bundle-Classpath>
                              <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
                              <Embed-Dependency>
                                  my-project-api
                              </Embed-Dependency>
                              <Export-Package></Export-Package>
                              <Import-Package>
                                  javax.ws.rs;version="[2.0,3)",
                                  javax.ws.rs.core;version="[2.0,3)",
                                  *</Import-Package>
                         </instructions>
                      </configuration>
</plugin>

org.apache.felix
maven捆绑插件
真的
捆
包裹
捆
${project.artifactId}
.
META-INF/persistence.xml
我的项目api
javax.ws.rs;version=“[2.0,3]”,
javax.ws.rs.core;version=“[2.0,3]”,
*

默认情况下,maven在src/main/resources目录中查找资源。它与maven bundle插件无关。要以不同的方式配置资源处理,请参阅下面的链接解释如何在主题“说明->包含资源”下的最后一个bundle中包含资源。

在文档之后,我在pom xml中的说明中添加了includeresource标记,如下所示,它起了作用,即插件从目标文件夹打包了资源文件

<instructions>
   <Include-Resource>
         META-INF/persistence.properties=target/classes/META-INF/persistence.properties
   </Include-Resource>
   <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
   <Bundle-Classpath>.</Bundle-Classpath>
   <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
   <Embed-Dependency>
           my-project-api
    </Embed-Dependency>
    <Export-Package></Export-Package>
    <Import-Package>
          javax.ws.rs;version="[2.0,3)",
          javax.ws.rs.core;version="[2.0,3)",
     *</Import-Package>
</instructions>

META-INF/persistence.properties=target/classes/META-INF/persistence.properties
${project.artifactId}
.
META-INF/persistence.xml
我的项目api
javax.ws.rs;version=“[2.0,3]”,
javax.ws.rs.core;version=“[2.0,3]”,
*

您的问题到底是什么?persistence.xml文件不在打包的jar文件中?@Balaza Zsoldos。问题是构建插件使用project src文件夹中的资源而不是使用project target文件夹中的资源来打包输出osgi bundle jar。我找到了一个maven bundle插件文档链接,其中解释了如何包含res目标包中的资源。巴拉兹。谢谢你帮助我。