Maven - what is maven - Maven Tutorial for Beginners - maven tutorial



maven tutorial tags : apache maven , maven repository , maven central

Introduction

  • We must first ensure that you have installed Maven into Eclipse
 Maven Introduction

learn maven tutorial - Maven Introduction - maven example

  • This is the image after Project completion:
 Maven Introduction1

learn maven tutorial - project explorer - maven example

Create Maven Project

  • In Eclipse, Click "New/Other"
 Create Maven Project

learn maven tutorial - Create Maven Project - maven example


 Create Maven Project1

learn maven tutorial - Create Maven Project step 1 - maven example


 Create Maven Project2

learn maven tutorial - Create Maven Project step 2 - maven example


 Create Maven Project3

learn maven tutorial - Create Maven Project step 3 - maven example


<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">
   <modelVersion>4.0.0</modelVersion>
   <groupId>wikitechy.com</groupId>
   <artifactId>HelloMaven</artifactId>
   <version>0.0.1-SNAPSHOT</version>
</project>
  • Open pom.xml file to configure the library will use
<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">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.o7planning</groupId>
   <artifactId>HelloMaven</artifactId>
   <version>0.0.1-SNAPSHOT</version>

   <dependencies>
       <dependency>
           <groupId>org.apache.commons</groupId>
           <artifactId>commons-lang3</artifactId>
           <version>3.3.2</version>
       </dependency>
   </dependencies>

</project>
  • Create class CheckNumeric.java
 Configure Maven

learn maven tutorial - Configure Maven - maven example

CheckNumeric.java

package wikitechy.tutorial.hellomaven;

import org.apache.commons.lang3.StringUtils;

public class CheckNumeric {

  public static void main(String[] args) {
      String text1 = "0123a4";
      String text2 = "01234";

      boolean result1 = StringUtils.isNumeric(text1);
      boolean result2 = StringUtils.isNumeric(text2);

      System.out.println(text1 + " is a numeric? " + result1);
      System.out.println(text2 + " is a numeric? " + result2);

  }

}

Output

 Configure Maven1

learn maven tutorial - Configure Maven step 1 - maven example

  • You can clearly see your project using the library. Where is its location on the hard drive.
 Configure Maven2

learn maven tutorial - Configure Maven step 2 - maven example

Installation Project with Maven

  • Here is compile and pack your Project by Maven
 Installation Project With Maven

learn maven tutorial - Installation Project With Maven - maven example

 Installation Project With Maven1

learn maven tutorial -Installation Project With Maven step 1 - maven example

 Installation Project With Maven2

learn maven tutorial - Installation Project With Maven step 2- maven example

maven tutorial tags : apache maven , maven repository , maven central

Explain the operating principles of Maven

  • Above you have created the project and ran flawlessly. The Project using StringUtils class, which to be a class of Apache, and not in the standard library of JDK. Traditionally you have to copy this library to project and declare the classpath.
  • However, the guidelines do not have to copy and declare classpath as the traditional way. The library was managed by Maven management. Now we will explain how Maven works:
 Operating Principles of Maven

learn maven tutorial - Operating Principles of Maven - maven example

  • The illustration above shows how the Maven done.
  • You declare in pom.xml, that project depend on common-lang3 library version 3.3.2.
  • As soon as you SAVE pom.xml file, Maven will check if this library has local repository on your computer yet. If has no, Maven will download it from the repository in the internet.
  • Finally, Maven will automatically declare Classpath.

View Local repository

  • Your question is where local repository located?
 View Local Repository

learn maven tutorial - View Local Repository - maven example

 View Local Repository1

learn maven tutorial - View Local Repository step 1 - maven example

 View Local Repository2

learn maven tutorial - View Local Repository step 2- maven example

 View Local Repository3

learn maven tutorial - View Local Repository step 3 - maven example

 View Local Repository4

learn maven tutorial - View Local Repository step 4 - maven example

 View Local Repository5

learn maven tutorial - View Local Repository step 5 - maven example

 View Local Repository6

learn maven tutorial - View Local Repository step 6 - maven example

 View Local Repository7

learn maven tutorial - View Local Repository step 7 - maven example

View Maven Repository on Internet

  • The question is where to lookup the information groupId, artifactId and version.
  • You can go to one of these sites:
  • http://search.maven.org
  • http://mvnrepository.com
 Maven Central Repository

learn maven tutorial - Maven Central Repository - maven example

 Maven Central Repository1

learn maven tutorial - Maven Central Repository step 1- maven example

 Maven Central Repository2

learn maven tutorial - Maven Central Repository step 2- maven example

Configuring Maven download source and javadoc

  • Normally Maven only download binary files. To Maven download the source and javadoc, you need to configure on Eclipse.
  • Windows/Preferences
 Maven Central Repository3

learn maven tutorial - Maven Central Repository step 3 - maven example

  • Change something in the pom.xml file and save (Or build project), Maven will download the source and javadoc.
  • The results you see on the Local Repository:
 Maven Central Repository4

learn maven tutorial - Maven Central Repository step 4 - maven example


Wikitechy provides an indepth knowledge on the below maven tutorial items such as maven download , maven install , maven goals , maven build , maven commands , maven plugin , maven search , maven eclipse , maven deploy , eclipse maven , maven junit , maven java , hibernate maven , maven project , java maven , maven version , maven proxy , maven 2 , maven pom , maven eclipse plugin , maven java version , maven properties , maven install windows , how to create maven project in eclipse , eclipse maven plugin , maven dependencies , what is maven in java , maven apache , maven project structure , how to install maven in eclipse

Related Searches to Maven Tutorial for Beginners