0
當我嘗試在失敗與下面的跟蹤Netbeans的Maven項目運行文件:的Maven無法運行該文件(LifecycleExecutionException)
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project Geodesy_Testing: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project Geodesy_Testing: Command execution failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed.
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:362)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:610)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:352)
... 21 more
我在代碼中沒有誤差修改編譯或警告。
主要方法:
public static void main(String[] args) {
boolean[] df = Utils.toBinary(17, 5);
boolean[] ca = Utils.toBinary(3, 3);
boolean[] icao = Utils.toBinary(0x1ab8, 24);
boolean[] result = Utils.concatArrays(df, ca, icao); // *
byte[] frame = Utils.booleansToBytes(result); // *
System.out.println(Utils.bytesToString(frame));
}
當我註釋掉與*運行細紋。
下面是實現這些方法:
public static byte[] booleansToBytes(boolean[] boolArr) {
if (boolArr.length % 8 != 0) {
throw new IllegalArgumentException("Boolean array size must be multiple of 8!");
}
byte[] byteArr = new byte[boolArr.length/8];
for (int i = 0; i < byteArr.length; i++) {
byteArr[i] = boolsToByte(boolArr, 8 * i);
}
return byteArr;
}
public static boolean[] concatArrays(boolean[]... arrays) {
boolean[] result = null;
int offset = 0;
for (int i = 0; i < arrays.length; i++) {
if (i == 0) {
result = Arrays.copyOf(arrays[i], arrays[i].length);
} else {
System.arraycopy(arrays[i], 0, result, offset, arrays[i].length);
}
offset += arrays[i].length;
}
return result;
}