How do you configure a Maven plugin in the pom.xml
file?
A) By adding a
<plugin>
element within the <build>
sectionB) By adding a
<dependency>
element within the <dependencies>
sectionC) By adding a
<repository>
element within the <repositories>
sectionD) By adding a
<plugin>
element within the <dependencyManagement>
sectionAnswer:
A) By adding a
<plugin>
element within the <build>
sectionExplanation:
To configure a Maven plugin, you add a <plugin>
element within the <build>
section of the pom.xml
file. Plugins extend the functionality of Maven and can be used to perform various tasks during the build process, such as compiling code, packaging, and running tests.
For example:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
In this example, the Maven Compiler Plugin is configured to use Java 8 for compiling the project.