0

我是 pom 新手,我运行下面的 pom.xml,它成功执行,但在目标文件夹下没有找到结果。

请告诉我如何执行我的 pom 以及我在哪里找到我的结果(例如:输出)

<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 会将你的项目打包成一个 jar 文件,位于 target/yy_artifactid-0.0.1-SNAPSHOT.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 回答