本文介绍了使用Maven插件测试中的org.apache.maven.repository.RepositorySystem进行组件查找异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 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)foo.FooTest.setUp($ F $)
$ b 我在 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>
任何想法?
解决方案最近我遇到了同样的例外。经过一番研究后,我发现maven-compat插件解决了这个问题:
< dependency>
< groupId> org.apache.maven< / groupId>
< artifactId> maven-compat< / artifactId>
< version> 3.0.5< / version>
< scope> test< / scope>
< / dependency>
I'm trying to use maven-plugin-testing-harness
version 2.1 with the following test case:
public class FooTest extends AbstractMojoTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}
public void testSomething() throws Exception {
// todo
}
}
The test fails at the setUp()
call:
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)
These dependencies I have in the 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>
Any ideas?
解决方案 Recently I faced the same exception. After a bit researching I found that maven-compat plugin solves the problem:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.0.5</version>
<scope>test</scope>
</dependency>
这篇关于使用Maven插件测试中的org.apache.maven.repository.RepositorySystem进行组件查找异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!