How to eidted pom.xml to put file contains Main class on root folder?

问题描述 投票:0回答:0

我有一个 Netbeans 16 Maven 项目,其中包含像 com.abc.mypackage 这样的包。我用我的 java 测试文件(包含主类)测试了 mypakage 文件夹中的主类。现在我想将测试文件 (CountryTest.java) 放在根文件夹中,这意味着与 src 文件夹和 pom.xml 相同的文件夹。我试过了,但没有成功。 (我使用了一个 jar 插件来构建带有外部库的 jar 文件,我不想更改它)

<?xml version="1.0" encoding="UTF-8"?>
<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>fi.tuni.prog3</groupId>
    <artifactId>jsoncountries</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <exec.mainClass>CountryTest</exec.mainClass>
    </properties>
    <dependencies>
    <!--  Gson: Java to JSON conversion -->
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.10.1</version>
      <scope>compile</scope>
    </dependency>
</dependencies>
<build>
     <plugins>
        <plugin>
        <groupId>com.jolira</groupId>
        <artifactId>onejar-maven-plugin</artifactId>
        <version>1.4.4</version>
        <executions>
          <execution>
            <configuration>
              <mainClass>CountryTest</mainClass>
              <onejarVersion>0.97</onejarVersion>
              <attachToBuild>true</attachToBuild>
            </configuration>
            <goals>
              <goal>one-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

你能帮我处理这个文件吗(pom.xml)

java maven netbeans pom.xml
© www.soinside.com 2019 - 2024. All rights reserved.