一尘不染

Maven和POM.xml中的插件

java

我刚开始使用Maven,并且阅读了插件是可以使用的其他组件。文件
的典型结构pom.xml

<project>
  <groupId>org.koshik.javabrains</groupId>
  <artifactId>JarName</artifactId> (A fldernamed JarName was created) 
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>JarName</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>
</project>

问题 :我应该在哪里插入plugin标签?例如以下内容:

<plugin>
  <groupId>org.jibx</groupId>
  <artifactId>jibx-maven-plugin</artifactId>
  <version>1.2.4</version>
  <executions>
    <execution>
      <goals>
        <goal>bind</goal>
      </goals>
    </execution>
  </executions>
</plugin>

在依赖之前还是在dependency标签之后?有关系吗?


阅读 155

收藏
2020-12-03

共1个答案

一尘不染

<project>
    <groupId>org.koshik.javabrains</groupId>
    <artifactId>JarName</artifactId> (A fldernamed JarName was created) 
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

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

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.jibx</groupId>
                <artifactId>jibx-maven-plugin</artifactId>
                <version>1.2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bind</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

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

如果使用Maven配置文件,也可以将插件放置在的<build>部分中<profile>。顺序无关紧要。

2020-12-03