0

私はpomが初めてで、正常に実行された以下のpom.xmlを実行しましたが、ターゲットフォルダーの下に結果が見つかりませんでした。

pom を実行する方法と、結果が見つかった場所を教えてください (Like : Outputs)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">   

  <modelVersion>4.0.0</modelVersion>

  <groupId>xx_groupid</groupId>
  <artifactId>yy_artifactid</artifactId>   
  <version>0.0.1-SNAPSHOT</version>   
  <packaging>jar</packaging>

  <name>yy_artifactid</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>


  <build>
    <plugins>

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>2.2</version>
      </plugin> 

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.15</version>
      </plugin>

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-report-plugin</artifactId>
          <version>2.15</version>
      </plugin>  

    </plugins>
  </build> 
</project>
4

1 に答える 1

0

pom が有効な場合は、次を試してください。

mvn package

すべてがうまくいけば、maven はプロジェクトを target/yy_artifactid-0.0.1-SNAPSHOT.jar の jar ファイルにパッケージ化します。

- 編集 -

Exec Maven Pluginを使用して Java プログラムを実行できます

プラグインを pom.xml に追加します。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <configuration>
        <executable>java</executable>
        <arguments>
        <argument>-classpath</argument>
        <classpath/>
        <argument>org.example.Main</argument>
        </arguments>
    </configuration>
</plugin>

org.example.Main を、静的エントリ メソッドを含むプログラムのメイン クラスに変更することを忘れないでください: ** public static void main (String[] args)**

次に実行します: mvn compile exec:exec

アプリケーションの単体テストを実行するには、テスト ケースを src/test/java フォルダーの下に置き、mvn testを実行します

于 2013-07-31T06:59:04.640 に答える