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

exec-maven-plugin exec: java失败:无法将配置值分配给类型java.lang.字符串数组

池兴邦
2023-03-14

执行mvn exec: java时,它无法正确解析配置参数,引发以下错误:

[错误]无法执行目标组织。科德豪斯。mojo:execmaven插件:1.2。1:project autotest程序上的java(默认cli):无法解析mojo org的配置。科德豪斯。mojo:execmaven插件:1.2。1:java:无法将配置值分配给java类型的数组。String:[-classpath,classpath{},-glue,com.company.test.cumber,-format,pretty,-format,html:C:\workspace\autotest\target]-

这是使用的插件配置(使用ApacheMaven 3.0.3):

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <goals>
                <goal>java</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <includeProjectDependencies>false</includeProjectDependencies>
        <includePluginDependencies>true</includePluginDependencies>
        <executableDependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
        </executableDependency>
        <mainClass>cucumber.cli.Main</mainClass>
        <commandlineArgs>-Dfile.encoding=UTF-8</commandlineArgs>
        <arguments>
            <argument>-classpath</argument>
            <classpath/>
            <argument>--glue</argument>
            <argument>com.company.test.cucumber</argument>
            <argument>--format</argument>
            <argument>pretty</argument>
            <argument>--format</argument>
            <argument>html:${project.basedir}\target</argument>
        </arguments>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.0.2</version>
        </dependency>
    </dependencies>
</plugin>

共有3个答案

尚楚
2023-03-14

如果你想使用

<executable>java</executable>

如果我理解正确,exec:java会自动添加无法覆盖的类路径。参数添加在主类之后exec:exec更为通用,它执行带有任何参数的任何可执行文件,其中一个参数可以是

訾安邦
2023-03-14

根据这里的exec:java文档,您必须:

删除代码

并使用

欧阳君浩
2023-03-14

我建议从配置中删除空条目,然后重试。

 <argument>-classpath</argument>
 <classpath/>

原因在java目标中,基于文档不允许类路径。

顺便说一句:永远不要在你的maven pom中使用“\”。改用正斜杠。

 类似资料: