gpt4 book ai didi

java - Maven 插件测试中 org.apache.maven.repository.RepositorySystem 的组件查找异常

转载 作者:IT老高 更新时间:2023-10-28 21:17:49 25 4
gpt4 key购买 nike

我正在尝试将 maven-plugin-testing-harness 2.1 版与以下测试用例一起使用:

public class FooTest extends AbstractMojoTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}
public void testSomething() throws Exception {
// todo
}
}

setUp() 调用测试失败:

org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.repository.RepositorySystem
roleHint:
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:257)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:239)
at org.codehaus.plexus.PlexusTestCase.lookup(PlexusTestCase.java:206)
at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:118)
at foo.FooTest.setUp(FooTest.java:54)

我在 pom.xml 中有这些依赖项:

    <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>

有什么想法吗?

最佳答案

最近我遇到了同样的异常(exception)。经过一番研究,我发现 maven-compat 插件解决了这个问题:

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.0.5</version>
<scope>test</scope>
</dependency>

关于java - Maven 插件测试中 org.apache.maven.repository.RepositorySystem 的组件查找异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15779351/

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