gpt4 book ai didi

java - org.codehaus.plexus.component.repository.exception.ComponentLookupException : java. util.NoSuchElementException

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:38:05 28 4
gpt4 key购买 nike

我尝试测试我的 Maven 插件并收到奇怪的异常。发现类似问题 here ,但答案没有帮助。

pom.xml

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>3.0-alpha-2</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aether</artifactId>
<version>0.10.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<version>3.3.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.3.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.3.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

测试类:

public class ConverterMojoTest {

@Rule
public MojoRule rule = new MojoRule() {

@Override
protected void before() throws Throwable {
super.before();
}

@Override
protected void after() {
super.after();
}
};

@Rule
public TestResources resources = new TestResources();


@Test
public void testExecute() throws Exception {
File project = resources.getBasedir("valid");
File pom = new File(project, "pom.xml");
Assert.assertNotNull(pom);
Assert.assertTrue(pom.exists());

ConverterMojo mojo = (ConverterMojo) rule.lookupMojo("convert", pom);
Assert.assertNotNull(mojo);
mojo.execute();
}
}

测试项目pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.my.utils.test</groupId>
<artifactId>project-to-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test</name>

<build>
<plugins>
<plugin>
<groupId>com.my.utils</groupId>
<artifactId>converter-maven-plugin</artifactId>
<configuration>

</configuration>
</plugin>
</plugins>
</build>
</project>

异常(exception):

org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.plugin.Mojo
roleHint: com.my.utils:converter-maven-plugin:1.0.0-SNAPSHOT:convert

最佳答案

我在一个具有适当目标的正确执行配置的模块中遇到了这个问题。我通过简单地在该特定模块中运行 mvn clean install 解决了这个问题(没有从本地存储库中删除任何内容)。

关于java - org.codehaus.plexus.component.repository.exception.ComponentLookupException : java. util.NoSuchElementException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34529565/

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