有没有一种方法可以在本地更新Maven的default-bindings.xml [英] Is there a way to update default-bindings.xml for maven on local

查看:120
本文介绍了有没有一种方法可以在本地更新Maven的default-bindings.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

听起来可能很蠢.但是有没有办法编辑或更新Maven的默认绑定文件?

It could sound dumb. But is there a way to edit or update the default-bindings file of maven?

/META-INF/plexus/default-bindings.xml

/META-INF/plexus/default-bindings.xml

我为什么要这样做?

背景-

  • 我正在使用计算机上最新的maven version 3.3.9作为intelliJ中的主目录.

  • I am using latest maven version 3.3.9 on my machine as a home directory within intelliJ.

我有一个名为testng-test的模块,未指定任何外部插件.看一下模块的pom.xml:

I have a module named testng-test without any external plugin specified. Take a look at the pom.xml for the module :

<artifactId>testng</artifactId>

<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.13.6</version>
    </dependency>
</dependencies>

  • 以及另一个名为junit-test的模块,该模块具有类似的pom.xml但具有不同的依存关系,如下所示:

  • And another module named junit-test with similar pom.xml but different dependency as follows :

    <artifactId>junit</artifactId>
    
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
    

  • 我在这些模块中添加了两个空类(尚无@Test方法或类).

  • I have added two empty classes within these modules(no @Test methods or classes still).

    活动-

    • 现在,当我尝试使用mvn clean install构建每个模块时,模块junit-test可以成功构建,但是模块testng-test失败并显示以下日志:
    • Now when I try to build each of these modules using mvn clean install, the module junit-test builds successfully, but the module testng-test fails with following logs :

    [INFO] --- maven-resources-plugin:2.6:resources(default-resources)@ testng ---

    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ testng ---

    [INFO] --- maven-compiler-plugin:3.1:compile(default-compile)@ testng ---

    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ testng ---

    [INFO] --- maven-resources-plugin:2.6:testResources(default-testResources)@ testng ---

    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ testng ---

    [INFO] --- maven-compiler-plugin:3.1:testCompile(default-testCompile)@ testng ---

    [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ testng ---

    [INFO] --- maven-surefire-plugin:2.12.4 :test(默认测试)@ testng ---

    [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ testng ---

    ,然后它会遇到SurefireReflectionException-

    运行TestNG6 org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException;嵌套的异常是 java.lang.reflect.InvocationTargetException:空 java.lang.reflect.InvocationTargetException 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:497) 在org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) 在org.apache.maven.surefire.booter.ProviderFactory $ ProviderProxy.invoke(ProviderFactory.java:165) 在org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) 在org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) 在org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) 引起原因:org.apache.maven.surefire.testset.TestSetFailedException: 未知的TestNG版本6.9.13.6

    Running TestNG6 org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) Caused by: org.apache.maven.surefire.testset.TestSetFailedException: Unknown TestNG version 6.9.13.6


    尝试-

    据我所知,如果我在<plugins>属性中将maven-surefire-plugin的插件版本显式更新为2.19.1,一切正常.

    To what I have noticed, if I explicitly update the plugin version for maven-surefire-plugin to 2.19.1 in the <plugins> property, things would just work fine.

    但是,如果我不想显式覆盖项目的插件版本,在这种情况下,我该如何使用最新的绑定(至少会解决这些问题)呢?

    But what if I would not want to explicitly override the plugin versions for the projects, in such case how do I go around using the latest bindings(atleast those would fix) for my project?

    查看默认绑定,我可以在

    Looking into the default bindings, I could see in the source code that the bindings are in the default-bindings.xml file for maven, but I am unable to find it inside my installed maven folder either to be possible to edit and update.

    那么有什么办法可以选择默认绑定来(默认情况下)为我要为我的项目列表上的任何maven模块指定执行的插件版本?

    推荐答案

    该文件位于jar中:

    ${MAVEN}/lib/maven-core-3.3.9.jar
    

    所以:

    ${MAVEN}/lib/maven-core-3.3.9/META-INF/plexus/default-bindings.xml
    

    这篇关于有没有一种方法可以在本地更新Maven的default-bindings.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆