Java
/
Maven
- 1 Basics 9
-
Classes
-
Objects
-
Arrays
-
Variables
-
Loops
-
Numbers
-
Strings
-
Exceptions
-
Regexp
- 2 OOP 9
-
Inheritance
-
Polymorphism
-
Static
-
Abstract
-
Interfaces
-
Constructors
-
Packages
-
Nested Classes
-
Final
- 3 Compiler 2
-
Sublime Text
-
Apache Ant
- 4 Collections 8
-
Lists
-
Comparable
-
Sets
-
Maps
-
Generics
-
Properties
-
Streams
-
Json
- 5 Threads 4
-
Create Thread
-
Sleep
-
Lock
-
Scheduler
- 6 Design patterns 4
-
Singleton
-
Observer
-
Strategy
-
Mediator
- 7 Swing 12
-
Frame
-
Panel
-
Listener
-
Combo Box
-
Label
-
Image
-
Menu
-
Table
-
Layout
-
Drawing
-
Timer
-
Designer
- 8 I/O 7
-
Streams IO
-
Socket
-
Watching Files
-
Mail
-
Logger
-
Clipboard
-
Encrypt
- 9 Effective 7
-
Constructors
-
Dependency Injection
-
Composition
-
Interfaces Default
-
Import Static
-
Enums
-
Lambdas
- 10 Junit 5
-
About Junit
-
Test Case
-
Suite Test
-
Annotations
-
Exceptions
- 11 Lambdas 7
-
Expressions
-
Functional Interfaces
-
Streams
-
Common Operations
-
Default Methods
-
Static Methods
-
Single Responsibility
- 12 JavaFX 6
-
Openjfx
-
Scene Builder
-
First App
-
Jar Archive
-
On Action
-
Change Listener
- 13 Maven 4
-
Demo
-
Spring Boot
-
Junit
-
Guava
- 14 Spring Boot 8
-
Quick start
-
Rest service
-
Consuming Rest
-
Templates
-
Security
-
Command Line
-
Scheduling Tasks
-
Ajax
/
Demo
➟
➟
Last update: 13-03-2022
Maven
With Maven, you can have better dependency management.
sudo apt-get update
sudo apt-get -y install maven
mvn -v
# Apache Maven 3.8.2
# To install on Windows download maven binary zip from apache website.
# Add /bin folder to your path and test maven installation.
Project
Setup a Java project for Maven to build.
/**
* Maven import library example (joda.time)
*/
package com.minte9.demo;
import org.joda.time.LocalTime;
public class DemoCurrentTime {
public static void main(String[] args) {
LocalTime currentTime = new LocalTime();
System.out.println(
"The current local time is: " + currentTime
);
}
}
Pom
Create Maven pom.xml project definition (next to src folder).
Compile
Compile and run the project.
cd D:\developments\myproject
mvn package
# mvn clean
# mvn install
# mvn compile
java -jar ./target/demo-maven-0.1.0.jar
# The current local time is: 16:57:00.610
M2
The .m2 repository is located in your home directory.
/home/catalin/.m2
# C:\Users\Catalin\.m2\repository
➥ Windows (2/2)Windows
Extract to directory and add to PATH environment.
PATH D:\apache-maven-3.8.4\bin
Version: mvn --version
# Apache Maven 3.8.4
Settings
D:\apache-maven-3.8.4\conf\settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0
http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<mirrors>
<mirror>
<id>Artifactory</id>
<name>Artifactory Public Mirror</name>
<url>
https://artifacts.myapps.com:443/artifactory/maven-central-remote/
</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
Certificate
Se Environment PATH generate and import certificate.
D:\openssl-1.1.1k-vs16-x86\bin
D:\>openssl version
OpenSSL 1.1.1k
cd D:\apache-maven-3.8.4
openssl s_client -showcerts -connect artifacts.myapps.com:443 |
openssl x509 -outform PEM > artifacts_ca.cer
echo %JAVA_HOME%
C:\Program Files (x86)\Java\jdk1.8.0_281
keytool -import -trustcacerts -keystore
"%JAVA_HOME%\jre\lib\security\cacerts" -storepass
myappspassword -alias Artifact -import -file artifacts_ca.cer
# important: JAVA_HOME\jre
mvn -version
Apache Maven 3.8.4
Maven home: D:\apache-maven-3.8.4
Java version: 1.8.0_281, runtime: jdk1.8.0_281\jre
Project
cd D:\maven\demo
mvn package
D:\maven\demo>java -jar target\demo-maven-0.1.0.jar
The current local time is: 12:04:45.864
➥ Questions github Maven