gpt4 book ai didi

apache - Maven bundle 问题,称为MNG-4338

转载 作者:行者123 更新时间:2023-12-04 13:24:35 24 4
gpt4 key购买 nike

我在使用Maven-Bundle-plugin时遇到问题:

我想将我的项目部署为osgi bundle 软件,因此我将打包软件作为 bundle 软件使用。
但是pom似乎不知道包装是一 bundle 。在这里您可以看到我的pom.xml:

<project ...>...
<packaging>bundle</packaging>
<version>1.0.0</version>

<name>Simple CXF project using spring configuration</name>

<properties>
<cxf-version>2.4.2</cxf-version>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.5</version>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>demo.hw.server</Export-Package>
<Bundle-Activator>demo.hw.server.Activator</Bundle-Activator>
<Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
</instructions>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>

</project>

他们说,此错误已得到修复(http://jira.codehaus.org/browse/MNG-4338),但对我来说似乎还没有。有人遇到过这个问题并找到解决方案吗?

错误消息是这样的:
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.talend.liugang.cxf:java_first_jaxws:1.0.0 (C:\Users\Andreas\workspace\java_first_jaxws\pom.xml) has 1 error
[ERROR] Unknown packaging: bundle @ line 7, column 13
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

最好的祝福,
赛恩

最佳答案

给定上面的pom示例,您应该将maven-bundle-plugin移到<pluginManagement>节点之外。 <pluginManagement>通常用于父poms中的继承目的。 bundle 的包装类型由maven-bundle-plugin提供(这就是为什么需要<extensions>true</extensions>的原因),因此在这种情况下,此插件必须位于<pluginManagement>之外。

<project ...>...
<packaging>bundle</packaging>
<version>1.0.0</version>

<name>Simple CXF project using spring configuration</name>

<properties>
<cxf-version>2.4.2</cxf-version>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.5</version>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>demo.hw.server</Export-Package>
<Bundle-Activator>demo.hw.server.Activator</Bundle-Activator>
<Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>

</project>

关于apache - Maven bundle 问题,称为MNG-4338,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7317575/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com