Horje
Default Values for Maven Properties

Apache Maven properties are key-value pairs that can be used to configure various of the build process. These properties can be defined in several places such as in the POM file, Settings file, or with the command line. Maven provides a set of default properties that are available for use in any Maven Project.

Default Maven Properties:

  • ${basedir}: The absolute path to the directory containing the POM file
  • ${project.build.directory}: The directory where the project is built.
  • ${project.build.outputDirectory}: The directory where compiled classes are placed.
  • ${project.build.testOutputDirectory}: The directory where compiled test classes are placed.
  • ${project.groupId}: The group ID of the project.
  • ${project.artifactId}: The artifact ID of the project.
  • ${project.version}: The version of the project.
  • ${project.packaging}: The packaging type of the project.
  • ${project.build.sourceDirectory}: The directory containing the source code.
  • ${project.build.testSourceDirectory}: The directory containing the test source code.
  • ${project.reporting.outputDirectory}: The directory where the project’s reports will be generated.
  • ${project.build.finalName}: The final name of the build artifact.

Tools and Technologies:

  • Java Version 17
  • Maven 3.X.X
  • Spring Tool Suite
  • Command Prompt
  • Java Programming
  • Maven Commands

Example

Here, we created a sample maven project by using Spring Initializr. And Below we provide required dependencies for your reference. Once project is created successfully, Then open the POM XML file and observe there are some default properties available in that file.

Dependencies:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-invoker</artifactId>
            <version>3.0.1</version>
        </dependency>

    </dependencies>


Folder Structure:

Folder Structure


pom.xml File:

XML
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.6</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.app</groupId>
    <artifactId>mavenbuild</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>mavenbuild</name>
    <description>Spring Reactive</description>

    <properties>
        <java.version>17</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.shared</groupId>
            <artifactId>maven-invoker</artifactId>
            <version>3.0.1</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


Key Default Properties in the Example Maven Project:

Here we provide some default properties in the above Maven Project. For your reference.

1. XML Version:

<?xml version="1.0" encoding="UTF-8"?>


2. Group ID:

<groupId>org.springframework.boot</groupId>


3. Artifact ID:

<artifactId>spring-boot-starter-parent</artifactId>


4. Version:

<version>3.2.6</version>


5. Relative Path:

<relativePath /> <!-- lookup parent from repository -->





Reffered: https://www.geeksforgeeks.org


Advance Java

Related
Maven Remote Repository Maven Remote Repository
Implementing Secure API Communication in Spring Boot Implementing Secure API Communication in Spring Boot
Maven POM Maven POM
Using Git as a Backend for Spring Cloud Config Server Using Git as a Backend for Spring Cloud Config Server
Difference Between hasRole() and hasAuthority() in Spring Security Difference Between hasRole() and hasAuthority() in Spring Security

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
13