在pom.xml(Maven项目)中指定目标时出现问题

relj7zay  于 2022-11-28  发布在  Maven
关注(0)|答案(1)|浏览(164)

我有下面的代码。
我正在尝试使用Mavenbukkit插件(Minecraft)创建**'pom.xml'**文件。

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>newestfile.here</groupId>
  <artifactId>newestplugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>2.3.2</version>
                 <executions>
                     <execution>
                            <goals>
                                  <goal>test</goal>
                            </goals>
                     </execution>
                 </executions>

这给了我错误:

    • 没有为此生成指定任何目标。必须指定有效的生命周期阶段或目标**

因此,我修改了代码,在**'exections'下面添加了3行,以设置我指定为'test'**的目标,假设我想运行代码并查看是否出现任何错误(即,它是否工作)。
然而,这给我带来了错误:'此插件目标无效:测试"。

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>newestfile.here</groupId>
  <artifactId>newestplugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>2.3.2</version>
                 <executions>
                     <execution>
                            <goals>
                                  <goal>test</goal>
                            </goals>
                     </execution>
                 </executions>

我会非常感激你的帮助!

rxztt3cl

rxztt3cl1#

我将版本更改为3.10.1,目标更改为17,如下所示,代码成功运行:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>newestfile.here</groupId>
  <artifactId>newestplugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>3.10.1</version>       
              <configuration>
                  <source>17</source>
                  <target>17</target>
              </configuration>   
        </plugin>
      </plugins>
    </pluginManagement>
</build>
   <repositories>
       <repository>
         <id>spigot-repo</id>
         <url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
       </repository>
   </repositories>
      <dependencies>
       <dependency>
           <groupId>org.spigotmc</groupId>
           <artifactId>spigot-api</artifactId>
           <version>1.16.5-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
           <type>jar</type>
           <scope>provided</scope>
       </dependency>
   </dependencies>
</project>

非常感谢你的帮助!

相关问题