当前位置: 首页 > 知识库问答 >
问题:

Fitnesse maven-classpath-plugin与Guava jar冲突

咸高谊
2023-03-14

我试图在我的项目中设置Fitnesse,但我面临着番石榴罐的一些问题这就是我的pom.xml的样子:

<dependencies>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>23.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.fitnesse/fitnesse -->
    <dependency>
        <groupId>org.fitnesse</groupId>
        <artifactId>fitnesse</artifactId>
        <version>20161106</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.fitnesse.plugins</groupId>
        <artifactId>maven-classpath-plugin</artifactId>
        <version>1.9</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

<profiles>
    <profile>
        <id>integration-test</id>
        <properties>
            <skip.unit.tests>false</skip.unit.tests>
        </properties>
    </profile>
    <profile>
        <id>standalone</id>
        <properties>
            <skip.unit.tests>true</skip.unit.tests>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.6</version>
                    <executions>
                        <execution>
                            <id>start-fitnesse</id>
                            <phase>test</phase>
                            <configuration>
                                <tasks>
                                    <echo taskname="fitnesse" message="Starting FitNesse..."/>
                                    <java classname="fitnesseMain.FitNesseMain"
                                          classpathref="maven.runtime.classpath" fork="true">
                                        <arg line="-p 9090"/>
                                        <arg line="-d ."/>
                                        <arg line="-o"/>
                                    </java>
                                </tasks>
                            </configuration>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        <dependencies>
        </dependencies>
    </profile>
</profiles>

我正在使用maven-classpath-plugin在Fitnesse中设置类路径。此插件瞬态使用org.sonatype.sisu: sisu-guava: jar: 0.9.9: runtimejar。我的项目还需要Guava jar。Maven依赖树:

[INFO] --- maven-dependency-plugin:3.0.1:tree (default-cli) @ testProject ---
[INFO] com.rdm:testProject:jar:1.0-SNAPSHOT
[INFO] +- com.google.guava:guava:jar:23.0:compile
[INFO] |  +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] |  +- com.google.errorprone:error_prone_annotations:jar:2.0.18:compile
[INFO] |  +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] |  \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] +- org.fitnesse:fitnesse:jar:20161106:runtime
[INFO] |  +- org.htmlparser:htmlparser:jar:2.1:runtime
[INFO] |  +- org.htmlparser:htmllexer:jar:2.1:runtime
[INFO] |  +- org.apache.velocity:velocity:jar:1.7:runtime
[INFO] |  +- commons-lang:commons-lang:jar:2.6:runtime
[INFO] |  +- commons-collections:commons-collections:jar:3.2.2:runtime
[INFO] |  +- org.json:json:jar:20151123:runtime
[INFO] |  +- com.googlecode.java-diff-utils:diffutils:jar:1.3.0:runtime
[INFO] |  +- org.apache.ant:ant:jar:1.9.6:runtime
[INFO] |  |  \- org.apache.ant:ant-launcher:jar:1.9.6:runtime
[INFO] |  \- junit:junit:jar:4.12:runtime
[INFO] |     \- org.hamcrest:hamcrest-core:jar:1.3:runtime
[INFO] \- org.fitnesse.plugins:maven-classpath-plugin:jar:1.9:runtime
[INFO]    \- org.apache.maven:maven-embedder:jar:3.0.4:runtime
[INFO]       +- org.apache.maven:maven-settings:jar:3.0.4:runtime
[INFO]       +- org.apache.maven:maven-core:jar:3.0.4:runtime
[INFO]       |  +- org.apache.maven:maven-model:jar:3.0.4:runtime
[INFO]       |  +- org.apache.maven:maven-settings-builder:jar:3.0.4:runtime
[INFO]       |  +- org.apache.maven:maven-repository-metadata:jar:3.0.4:runtime
[INFO]       |  +- org.apache.maven:maven-artifact:jar:3.0.4:runtime
[INFO]       |  +- org.apache.maven:maven-aether-provider:jar:3.0.4:runtime
[INFO]       |  |  \- org.sonatype.aether:aether-spi:jar:1.13.1:runtime
[INFO]       |  +- org.sonatype.aether:aether-impl:jar:1.13.1:runtime
[INFO]       |  +- org.sonatype.aether:aether-api:jar:1.13.1:runtime
[INFO]       |  +- org.sonatype.aether:aether-util:jar:1.13.1:runtime
[INFO]       |  \- org.codehaus.plexus:plexus-interpolation:jar:1.14:runtime
[INFO]       +- org.apache.maven:maven-plugin-api:jar:3.0.4:runtime
[INFO]       +- org.apache.maven:maven-model-builder:jar:3.0.4:runtime
[INFO]       +- org.apache.maven:maven-compat:jar:3.0.4:runtime
[INFO]       |  \- org.apache.maven.wagon:wagon-provider-api:jar:2.2:runtime
[INFO]       +- org.codehaus.plexus:plexus-utils:jar:2.0.6:runtime
[INFO]       +- org.codehaus.plexus:plexus-classworlds:jar:2.4:runtime
[INFO]       +- org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:runtime
[INFO]       |  \- org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:runtime
[INFO]       |     \- org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:runtime
[INFO]       |        \- org.sonatype.sisu:sisu-guava:jar:0.9.9:runtime
[INFO]       +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:runtime
[INFO]       +- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:runtime
[INFO]       +- org.sonatype.plexus:plexus-cipher:jar:1.7:runtime
[INFO]       \- commons-cli:commons-cli:jar:1.2:runtime

这是我在尝试启动fitnesse服务器时遇到的错误:

[fitnesse] Starting FitNesse...
     [java] SEVERE: Error while starting the FitNesse [Unable to instantiate component for type fitnesse.wikitext.widgets.MavenClasspathSymbolType]
     [java] fitnesse.components.ComponentInstantiationException: Unable to instantiate component for type fitnesse.wikitext.widgets.MavenClasspathSymb
olType
     [java]     at fitnesse.components.ComponentFactory.createComponent(ComponentFactory.java:75)
     [java]     at fitnesse.plugins.PropertyBasedPluginFeatureFactory$8.register(PropertyBasedPluginFeatureFactory.java:152)
     [java]     at fitnesse.plugins.PropertyBasedPluginFeatureFactory.forEachClass(PropertyBasedPluginFeatureFactory.java:144)
     [java]     at fitnesse.plugins.PropertyBasedPluginFeatureFactory.forEachObject(PropertyBasedPluginFeatureFactory.java:150)
     [java]     at fitnesse.plugins.PropertyBasedPluginFeatureFactory.registerSymbolTypes(PropertyBasedPluginFeatureFactory.java:75)
     [java]     at fitnesse.plugins.PluginsLoader.loadSymbolTypes(PluginsLoader.java:87)
     [java]     at fitnesse.ContextConfigurator.makeFitNesseContext(ContextConfigurator.java:151)
     [java]     at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:69)
     [java]     at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:58)
     [java]     at fitnesseMain.FitNesseMain.mai
     [java] n(FitNesseMain.java:38)
     [java] Caused by: java.lang.reflect.InvocationTargetException
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
     [java]     at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
     [java]     at fitnesse.components.ComponentFactory.createComponent(ComponentFactory.java:72)
     [java]     ... 9 more
     [java] Caused by: java.lang.NoSuchMethodError: com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/c
oncurrent/ConcurrentMap;
     [java]     at com.google.inject.internal.Annotations$AnnotationChecker.<init>(Annotations.java:104)
     [java]     at com.google.inject.internal.Annotations.<clinit>(Annotations.java:122)
     [java]     at com.google.inject.Key.ensureRetainedAtRuntime(Key.java:362)
     [java]     at com.google.inject.Key.strategyFor(Key.java:354)
     [java]     at com.google.inject.Key.get(Key.java:222)
     [java]     at org.sonatype.guice.bean.binders.ParameterKeys.<clinit>(ParameterKeys.java:23)
     [java]     at org.codehaus.plexus.DefaultPlexusContainer$ContainerModule.configure(DefaultPlexusContainer.java:801)
     [java]     at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
     [java]     at com.google.inject.spi.Elements.getElements(Elements.java:103)
     [java]     at com.google.inject.spi.Elements.getElements(Elements.java:80)
     [java]     at org.sonatype.guice.bean.binders.MergedModule.configure(MergedModule.java:54)
     [java]     at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
     [java]     at com.google.inject.spi.Elements.getElements(Elements.java:103)
     [java]     at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
     [java]     at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
     [java]     at com.google.inject.Guice.createInjector(Guice.java:94)
     [java]     at com.google.inject.Guice.createInjector(Guice.java:71)
     [java]     at com.google.inject.Guice.createInjector(Guice.java:61)
     [java]     at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:470)
     [java]     at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:196)
     [java]     at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:160)
     [java]     at fitnesse.wikitext.widgets.MavenClasspathExtractor.buildPlexusContainer(MavenClasspathExtractor.java:219)
     [java]     at fitnesse.wikitext.widgets.MavenClasspathExtractor.buildPlexusContainer(MavenClasspathExtractor.java:215)
     [java]     at fitnesse.wikitext.widgets.MavenClasspathExtractor.<init>(MavenClasspathExtractor.java:51)
     [java]     at fitnesse.wikitext.widgets.MavenClasspathSymbolType.<init>(MavenClasspathSymbolType.java:39)
     [java]     ... 14 more

现在,如果在maven类路径插件之后声明Guava依赖项,那么我不会遇到这个问题,但是我的单元测试和集成测试失败,出现了MethodNotFoundException,如果我在maven类路径插件之上声明Guava依赖项,那么fitnesse服务器不会出现如上所示的错误。

我看到了一个类似的问题6 sisu guava与guava冲突

任何建议或解决办法都将非常有帮助。

编辑:找到了一个更简单的解决方案-我在pom中添加了以下依赖项。xml:

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-embedder</artifactId>
    <version>3.5.0</version>
    <scope>runtime</scope>
</dependency>

从而停止了sisu guava的可传递下载。现在,测试和fitnesse服务器都可以工作了

共有1个答案

沈琛
2023-03-14

这似乎与Fitnesse Maven类路径错误非常相似。使用我在这里提到的两种方法之一来处理wiki库和运行测试的装置之间的依赖性冲突。

 类似资料:
  • composer 安装 fxp/composer-asset-plugin:~1.3.0 报错,具体错误内容如下: 百度了各种结果,都不是我这种问题,特请大佬帮忙看看,该如何解决,谢谢。

  • 问题内容: 我有一个关于在Jar文件()中编译具有某些依赖类的类的问题。通过将目录树放在-classpath选项中(例如:),是否将检查所有子目录中的类或仅检查目录树中的顶级类?提前致谢。 问题答案: 是否会递归搜索指定的目录:否 当类加载器进入在类路径中指定的目录时,它将使用该类所在的子目录开始。如果未指定包,则类加载器将其放在目录的直接子级(类文件)下。 它是直接货币/罐和的组合。 假设您具有

  • GNU Classpath(Java 的基本类库)是为了建立自由核心类库使用虚拟机和编译器的Java编程语言。它包括所有本地方法和核心课程是完全必要的功能Java运行。

  • 我使用pybind11让python调用现有的C模块(库)。但是,在C库中,调用::GetModuleFileName(Visual Studio)来确定加载的模块在C中运行时的物理路径。但是当我通过pybind11从python(Jupyter Notebook)调用库时,python.exe的物理路径会返回。如何配置或更改以确保获得C库的物理路径? C代码是这样的:Lib. h 我ib.cpp

  • 我使用的是Horizontal ViewPager2,它里面有4个片段。每个片段都有一个回收器视图上的SwipeReFresLayout。我面临的问题是,当回收器视图位于顶部时,然后onClick on任何项目列表都不起作用。如果我向下滚动一点回收器视图,那么onClick就可以正常工作。当回收器视图位于顶部时,如果SwipeReFresLayout处于刷新状态,那么onClick就可以正常工作。

  • 有了这个Jaxb Xml定义,我尝试通过添加来移除映射元素包装器,但在解压缩过程中会导致异常 EventAdapter是 我的输出是 我尝试通过添加来删除标记 产量不错 但撤退失败了 调试Jaxb使我熟悉了这一行