6

私はmavenを初めて使用し、mavenを介してクラスファイルを実行しているときに問題に直面しています

mvn exec:java -Dexec.mainClass="com.test.Test"で正常に動作します

ただし、
mvn exec:exec -Dexec.executable=java -Dexec.mainClass="com.test.Test"ではありません

Javaパラメータを要求します

F:\data\work\Test>mvn exec:exec -Dexec.executable=java -Dexec.mainClass="com.test.Test"
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
    -hotspot      is a synonym for the "server" VM  [deprecated]
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.

私はすでにクラスファイルを提供していますが、なぜそれを選択できないのですか? poでも提供してみました。

MAVEN_OPTSから VM 引数を渡したくないので、exec:exec を使用しています。

これが私のポンです

<profiles>  
 <profile>  
  <id>fib</id>  
  <build>  
   <plugins>  
    <plugin>  
     <groupId>org.codehaus.mojo</groupId>  
     <artifactId>exec-maven-plugin</artifactId>  
     <version>1.3.2</version>  
     <executions>  
      <execution>  
       <phase>test</phase>  
       <goals>  
        <goal>exec</goal>  
       </goals>  
       <configuration>  
        <mainClass>com.test.Test</mainClass>  
        <executable>java</executable> 
       </configuration>  
      </execution>  
     </executions>  
    </plugin>  
   </plugins>  
  </build>  
 </profile>  
</profiles>

私は何が欠けていますか?

したがって、発生する2つの質問
-1)mainClassを渡しているにもかかわらず、Javaパラメーターを渡すように求めているということで、何が欠けていますか?
2) exec-maven-plugin を使用して VM 引数を渡すにはどうすればよいですか?

引数付きのmaven 'exec:exec'を使用して、2番目の質問でこれを見つけました

4

1 に答える 1

6
mvn exec:exec -Dexec.executable=java -Dexec.args="-classpath target/classes -XX:+PrintGCDetails com.test.Test"

また、依存関係がクラスパスにあることに懸念がある場合は、ファット jarを作成してクラスパスに設定します。

興味深い議論: https://chat.stackoverflow.com/rooms/67085/discussion-between-biker-and-jigar-joshi

于 2014-12-17T06:57:31.510 に答える