1

Maven ビルド後に Izpack インストーラーを実行したいのですが、「mvn test」を実行した後に次の出力が得られます。

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building RS IzPack installer
[INFO]    task-segment: [test]
[INFO] ------------------------------------------------------------------------
[debug] execute contextualize
[INFO] [resources:copy-resources {execution: copy-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 109 resources
[INFO] Copying 4 resources
[INFO] Preparing exec:java
[WARNING] Removing: java from forked lifecycle, to prevent recursive invocation.
[debug] execute contextualize
[INFO] [resources:copy-resources {execution: copy-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 109 resources
[INFO] Copying 4 resources
[INFO] [exec:java {execution: default}]
[WARNING]
java.lang.ClassNotFoundException: com.izforge.izpack.installer.Installer
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
        at java.lang.Thread.run(Thread.java:595)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An exception occured while executing the Java class. com.izforge.izpack.installer.Installer

生成されたjarファイルを何らかの方法でクラスパスに配置する必要があるように見えますが、何かアイデアはありますか?

私の pom.xml からの抜粋:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
      <execution>
        <phase>test</phase>
        <goals>
          <goal>java</goal> <!-- "exec" also possible -->
        </goals>
        <configuration>
          <mainClass>com.izforge.izpack.installer.Installer</mainClass>
          <arguments>
            <argument>-console</argument>
            <!-- <argument>arg1</argument> -->
          </arguments>
        </configuration>
      </execution>
    </executions>
  </plugin>

Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200) Java バージョン: 1.6.0_20 Java ホーム: C:\Java\jdk16\jre デフォルト ロケール: en_GB、プラットフォーム エンコーディング: Cp1252 OS 名: 「windows xp」 バージョン: 「5.1」 アーキテクチャ: 「x86」 ファミリー: 「windows」

マーティン

4

3 に答える 3

0

そのようなものを使用して、その実行の依存関係を定義できます。

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
  <execution>
    <phase>test</phase>
    <goals>
      <goal>java</goal> <!-- "exec" also possible -->
    </goals>
    <configuration>
      <mainClass>com.izforge.izpack.installer.Installer</mainClass>
      <arguments>
        <argument>-console</argument>
        <!-- <argument>arg1</argument> -->
      </arguments>
    </configuration>
  </execution>
</executions>
<dependencies>
  <dependency>
    <groupId>org.codehaus.izpack</groupId>
    <artifactId>izpack-standalone-compiler</artifactId>
    <version>4.3.4</version>
    <scope>compile</scope>
  </dependency>
</dependencies>

しかし、 izpack 用の Maven プラグインもあります。

于 2011-09-27T09:23:12.220 に答える
0

javaを使用してコマンドのクラスパスを定義する必要があると思います-classpathcom.izforge.izpack.installer.Installerメインクラスとそのすべての依存関係を含むクラスパスを構築する必要があります。jar、クラスフォルダー、または複数のjarに入れることができます。Java 呼び出しのクラスパスを定義する方法については、ウィキペディアを参照してください。

于 2011-09-27T08:34:19.180 に答える
0

瓶の中を見たことがありますか?Maven が必要なクラスを jar に含めていない可能性があります。

于 2011-09-27T08:26:18.823 に答える