我正在构建.kar文件,但是当我运行mvn package
时,我收到此错误:
[INFO] --- maven-bundle-plugin:2.4.0:bundle (default-bundle) @ common ---
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/istack
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-core, Jar:istack-commons-runtime]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/model/impl
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/marshaller
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/runtime/unmarshaller
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/util
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/unmarshaller
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/istack/logging
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-core, Jar:istack-commons-runtime]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/api
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/util
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/runtime
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/istack/localization
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-core, Jar:istack-commons-runtime]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
[WARNING] Bundle se.eman.path.to.my.package:common:bundle:1.0.0-SNAPSHOT : Split package, multiple jars provide the same package:com/sun/xml/bind/v2/model/annotation
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in [Jar:jaxb-impl, Jar:jaxb-core]
Class path [Jar:., Jar:camel-core, Jar:slf4j-api, Jar:jaxb-impl, Jar:jaxb-core, Jar:jaxb-api, Jar:istack-commons-runtime, Jar:FastInfoset, Jar:jsr173_api, Jar:camel-groovy, Jar:groovy-all, Jar:commons-logging, Jar:slf4j-log4j12,
Jar:log4j]
我的pom .xml:
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.common</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<!-- TODO: Insert your needed exports here -->
<Export-Package>*,se.eman.path.to.my.package.*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
我无法弄清楚造成这些错误的原因。当我阅读拆分包时,我得到了一个非常有用的建议,即应该避免拆分包。是的......我无法控制jaxb-impl,jaxb-core或com / sun /*。
有关如何解决此问题的任何想法?
答案 0 :(得分:3)
Export-Package的默认值为{local-packages}
而不是*
使用指令Export-Package: *
,您要求bnd导出项目的所有依赖项。
删除*或使用{local-packages}
修改:
请注意,您只应从Bundle导出公共API。其他一切都应该保密。默认情况下,maven-bundle-plugin导出所有包,但包含impl
或internal
的包除外。如果可以,您应该坚持使用此约定并省略Export-Package
指令,或明确导出您的公共包。
答案 1 :(得分:0)
示例为我工作:
<Export-Package>
org.hibernate.*;version=${pkgVersion};-split-package:=merge-last
</Export-Package>