Maven Tutorial for Beginners - with Examples In28Minutes

Image

Installing Eclipse and Java

https://github.com/in28minutes/SpringIn28Minutes/blob/master/InstallationGuide-JavaEclipseAndMaven_v2.pdf

Course Overview

Step List

Lets now look at the steps in this tutorial.

Running Examples

Youtube Video

https://courses.in28minutes.com/p/maven-tutorial-for-beginners-in-5-steps

0. What is Maven?

Defining what Maven does is very difficult.

Every Day Developer

    Manages Dependencies - Web Layer (Spring MVC), Data Layer (JPA - Hibernate) etc..                  
    Build a jar or a war or an ear
    Run the application locally - Tomcat or Jetty
    Deploy to a T environment
    Add new dependencies to a project
    Run Unit Tests

Maven helps us do all these and more...

    Generate Projects
    Create Eclipse Workspace

1. Beginner Maven Project

What is the power of Maven?

First Project : My aim is to create a Spring.jar. Think as if you are developing Spring. Some other developers want to use the framework you are developing. Steps in creating a JAr

Convention over Configuration

You are ready for theory on Build Life Cycle

Pre-defined sequence of steps that are done when we run a maven command. Plugins can be attached to lifecycle stages. Default plugins are already defined in the super pom.

mvn install

Build LifeCycle

    Validate
    Compile
    Test
    Package
    Integration Test
    Verify
    Install
    Deploy

Lets understand pom.xml

Project Object Model (POM)

    Name (if another project want to refer to our project, how do they do it?)
    Version (Major Version, Minor Version, Incremental Version)
    Packaging 
    Dependencies
    Plugins

Maven repository stores all the versions of all dependencies. JUnit 4.2,4.3,4.4

Local Repository - all the dependencies that are downloaded for 1st time are stored.

2. Intermediate Maven Project

Dependency Management

    Scope
    Transitive Dependencies
    Excluding Dependency
    Dependency Versions

Sample Project Object Model

    Maven Plugins
    Convention over configuration
        Source Code
            ${basedir}/src/main/java
            ${basedir}/src/main/resources
        Test Code
            ${basedir}/src/test

Hierarchy of POMS

    Super POM

3. Multi Module Maven Project

4. Maven Web Application

Packaging

    War
    Ear

Running application in Tomcat

5. Tip and Tricks

Important Commands

    help:effective-settings
    help:effective-pom
    dependency:tree
    dependency:sources
    --debug

Maven Archetypes

    archetype:generate

6. Missing (To Discuss)

Expectations

Running Examples

Troubleshooting

Youtube Playlists - 500+ Videos

Click here - 30+ Playlists with 500+ Videos on Spring, Spring Boot, REST, Microservices and the Cloud

Keep Learning in28Minutes

in28Minutes is creating amazing solutions for you to learn Spring Boot, Full Stack and the Cloud - Docker, Kubernetes, AWS, React, Angular etc. - Check out all our courses here