Maven Spring Project
Maven Spring Project
Java
pom.xml in a maven
based Spring Project
@techwithvishalraj
<project></project>
<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">
.......
</project>
<groupId>com.example</groupId>
<artifactId>my-spring-boot-app</artifactId>
<version>1.0.0</version>
<name>spring-boot-multi-module-project</name>
<description>Demo project for Spring Boot</description>
groupId: This is generally unique for a project. For example, all core Maven
artifacts do should live under the groupId – org.apache.maven.
artifactId: The artifactId is generally the name that the project is known by.
version: defines the version of the project.
name: Name of the app.
description: description of the app.
Properties
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.3.9</spring.version>
</properties>
POM Relationships
dependencies
inheritance
aggregation
Dependency Management
<dependencyManagement>
<dependencies>
<!-- Define managed dependencies here -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>4.12</version>
<classifier>sources</classifier>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
<systemPath>/path/to/example-library.jar</systemPath>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Add more managed dependencies as needed -->
</dependencies>
</dependencyManagement
@techwithvishalraj
Inheritence in maven
...
<packaging>pom</packaging>
...
The packaging type required to be pom for parent and aggregation (multi-
module) projects.
When no packaging is declared, Maven assumes the packaging is the default:
jar. but you can change it war or any other types such as pom, jar, maven-
plugin, ejb, war, ear, rar.
...
<modules>
<module>my-project</module>
<module>another-project</module>
<module>third-project/pom-example.xml</module>
</modules>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<classifier>test</classifier>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
@techwithvishalraj
Thank
you!
vishal-bramhankar
techwithvishalraj
Vishall0317