gpt4 book ai didi

java - Maven 与 Ant : exec Command line

转载 作者:行者123 更新时间:2023-11-30 08:10:23 25 4
gpt4 key购买 nike

我想通过运行 pom.xml 中的 ant 任务来检索我的计算机的序列号。

<profile>
<id>generate-license</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<exec executable="wmic bios get serialnumber"
resultproperty="serialNumber"
failonerror="false" />
<echo message="Serial number: ${serialNumber}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

我在编译阶段执行maven,结果如下:

[WARNING] Parameter tasks is deprecated, use target instead
[INFO] Executing tasks

主要:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------ [INFO] Total time: 1:48.264s
[INFO] Finished at: Wed May 27 10:17:57 GMT+01:00 2015
[INFO] Final Memory: 11M/121M
[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (default) on project runner: An Ant BuildException has occured: Execute failed: java.io.IOExcept ion: Cannot run program "wmic bios get serialnumber": CreateProcess error=2, Le fichier spÚcifiÚ est introuvable
[ERROR] around Ant part ...... @ 4:100 in C:\xxx\yyy\target\antrun\build-main.xml

最佳答案

您可以尝试使用以下语法来传递参数吗?

<exec executable="wmic" resultproperty="serialNumber" failonerror="false">
<arg value="bios" />
<arg value="get" />
<arg value="serialnumber" />
</exec>

关于java - Maven 与 Ant : exec Command line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30478428/

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