为什么我会收到这个“拆分包"?警告? [英] Why am I getting this "split package" warning?
问题描述
我正在构建.kar文件,但是运行mvn package
时出现此错误:
I'm building a .kar-file, but when I run mvn package
I'm getting this error:
[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:
My 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/*.
I just can't figure out what's causing these errors. When I read up on split package I get the very helpful advice that split package should be avoided. Yeah... I have no control what so ever over jaxb-impl, jaxb-core or com/sun/*.
关于如何解决此问题的任何想法?
Any ideas on how to troubleshoot this?
推荐答案
Export-Package的默认值为{local-packages}
,而不是*
The default value for Export-Package is {local-packages}
and not *
使用指令Export-Package: *
,您正在要求bnd导出项目的所有依赖项.
With the directive Export-Package: *
, you are asking bnd to export all the dependencies of your project.
删除*或使用{local-packages}
编辑:
请注意,您仅应从捆绑包中导出公共API.其他所有东西都应该保密.默认情况下,maven-bundle-plugin导出所有软件包,但包含impl
或internal
的软件包除外.如果可以,则应遵循此约定并省略Export-Package
指令,或显式导出公共包.
Note that you should only export public API from a Bundle. Everything else should be keep private. By default, maven-bundle-plugin export all packages, except package containing impl
or internal
. If you can, you should stick with this convention and omit the Export-Package
directive, or explicitly export your public packages.
这篇关于为什么我会收到这个“拆分包"?警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!