gpt4 book ai didi

java - 如何解决 joda-time 和 org.joda 之间的包冲突

转载 作者:行者123 更新时间:2023-12-02 04:46:37 46 4
gpt4 key购买 nike

当我启动我的应用程序时,virgo 会抛出这样的异常:

[2015-09-05 11:27:53.254]  TCP Connection(2)-127.0.0.1 <DE0002E> Installation of bundle 'com.onboard.web.api' version '3.0.0.SNAPSHOT' failed. org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'com.onboard.web.api' at version '3.0.0.SNAPSHOT': Cannot resolve: com.onboard.web.api
Resolver report:
Uses violation: <Import-Package: org.springframework.format.datetime.joda; version="0.0.0"> in bundle <com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]>
Found conflicts:
package 'org.joda.time_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
conflicts with 'org.joda.time_2.3.0' in bundle 'joda-time_2.3.0[147]' used by 'com.onboard.service.github_3.0.0.SNAPSHOT' in bundle 'com.onboard.service.github_3.0.0.SNAPSHOT[189]'
package 'org.joda.time_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
conflicts with 'org.joda.time_2.3.0' in bundle 'joda-time_2.3.0[147]' used by 'com.onboard.service.github_3.0.0.SNAPSHOT' in bundle 'com.onboard.service.github_3.0.0.SNAPSHOT[189]'
package 'org.joda.time.format_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
conflicts with 'org.joda.time.format_2.3.0' in bundle 'joda-time_2.3.0[147]' imported by bundle 'com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]'
package 'org.joda.time.format_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
conflicts with 'org.joda.time.format_2.3.0' in bundle 'joda-time_2.3.0[147]' imported by bundle 'com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]'
package 'org.springframework.core.convert.converter_3.1.0.RELEASE' in bundle 'org.springframework.core_3.1.0.RELEASE[61]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
conflicts with 'org.springframework.core.convert.converter_3.1.0.RELEASE' in bundle 'org.springframework.core_3.1.0.RELEASE[112]' used by 'org.springframework.web.servlet.tags_3.1.0.RELEASE' in bundle 'org.springframework.web.servlet_3.1.0.RELEASE[168]'
package 'org.springframework.core.convert.converter_3.1.0.RELEASE' in bundle 'org.springframework.core_3.1.0.RELEASE[61]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[60]'
conflicts with 'org.springframework.core.convert.converter_3.1.0.RELEASE' in bundle 'org.springframework.core_3.1.0.RELEASE[112]' used by 'org.springframework.web.servlet.config.annotation_3.1.0.RELEASE' in bundle 'org.springframework.web.servlet_3.1.0.RELEASE[168]'
package 'org.joda.time_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[111]'
conflicts with 'org.joda.time_2.3.0' in bundle 'joda-time_2.3.0[147]' used by 'com.onboard.service.github_3.0.0.SNAPSHOT' in bundle 'com.onboard.service.github_3.0.0.SNAPSHOT[189]'
package 'org.joda.time_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[111]'
conflicts with 'org.joda.time_2.3.0' in bundle 'joda-time_2.3.0[147]' used by 'com.onboard.service.github_3.0.0.SNAPSHOT' in bundle 'com.onboard.service.github_3.0.0.SNAPSHOT[189]'
package 'org.joda.time.format_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[111]'
conflicts with 'org.joda.time.format_2.3.0' in bundle 'joda-time_2.3.0[147]' imported by bundle 'com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]'
package 'org.joda.time.format_1.6.0' in bundle 'com.springsource.org.joda.time_1.6.0[89]' used by 'org.springframework.format.datetime.joda_3.1.0.RELEASE' in bundle 'org.springframework.context_3.1.0.RELEASE[111]'
conflicts with 'org.joda.time.format_2.3.0' in bundle 'joda-time_2.3.0[147]' imported by bundle 'com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]'

Uses violation: <Import-Package: org.hibernate.validator.constraints.impl; version="0.0.0"> in bundle <com.onboard.web.api_3.0.0.SNAPSHOT[1441423661083]>
Resolver reported uses conflict for import constrained to bundle <com.springsource.org.hibernate.validator> constrained bundle version range "[4.2.0.Final,4.2.0.Final]"

at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.QuasiResolveStage.process(QuasiResolveStage.java:46)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessGraph(CompensatingPipeline.java:73)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessGraph(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:359)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:185)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:140)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:253)
at org.eclipse.virgo.kernel.deployer.management.StandardDeployer.deploy(StandardDeployer.java:52)
at sun.reflect.GeneratedMethodAccessor111.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:193)
at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:175)
at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:117)
at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:54)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)
at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1487)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)
at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

我发现我有两个依赖:

<dependency>
<groupId>com.onboard</groupId>
<artifactId>com.onboard.domain.model</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>com.springsource.org.hibernate.validator</artifactId>
<version>4.2.0.Final</version>
</dependency>

模型依赖joda-time:

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>

和hibernate.validator依赖org.joda:

<dependency>
<groupId>org.joda</groupId>
<artifactId>com.springsource.org.joda.time</artifactId>
<version>1.6.0</version>
<scope>compile</scope>
</dependency>

Joda-time的版本是2.3,org.joda的版本是1.6.0。 Joda-time 和 org.joda 都提供包 org.joda.time...。但是构建 MANIFEST.MF 的 Maven bundle 插件只有这样的 joda 时间包:

org.joda.time;version="[2.3,3)",org.joda.time.format;version="[2.3,3)"

所以当应用程序启动时,它们会发生冲突。

最佳答案

为什么需要这两个包?我尝试使用 joda-time 安装 com.springsource.org.hibernate.validator,它看起来像预期的那样工作。另一方面,如果您认为删除 com.springsource.org.joda.time 是个坏主意,您可以删除 joda-time 并仅使用 com.springsource.org.joda.time。

或者,您可以制作一个包含 joda-time 和 com.springsource.org.joda.time 的包。使用BND捆绑插件你可以做这样的事情:

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.joda</groupId>
<artifactId>com.springsource.org.joda.time</artifactId>
<version>1.6.0</version>
<scope>compile</scope>
</dependency>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_failok>true</_failok>
...
<Export-Package>org.joda.time*</Export-Package>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
...
</instructions>
</configuration>
</plugin>

希望对您有所帮助!

关于java - 如何解决 joda-time 和 org.joda 之间的包冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32409338/

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