π§© Install Local JAR
Manually install a dependency when it cannot be downloaded from Maven Central (Oracle, IBM, internal JARs).
mvn install:install-file \
-Dfile=ojdbc8.jar \
-DgroupId=com.oracle.database.jdbc \
-DartifactId=ojdbc8 \
-Dversion=19.3.0.0 \
-Dpackaging=jar
Common Use Cases
- Oracle JDBC drivers
- Telecom / vendor SDKs
- Internal utilities not published yet
π’ Deploy to Nexus/Artifactory
Publish any standalone JAR to your internal Maven repository.
mvn deploy:deploy-file \
-Durl=http://nexus.myorg.com/repository/maven-releases/ \
-DrepositoryId=nexus \
-Dfile=my-util.jar \
-DgroupId=com.myorg.util \
-DartifactId=my-util \
-Dversion=1.0.0 \
-Dpackaging=jar
Requirements
- Configure
repositoryIdinsettings.xml - Ensure credentials are set up
- Use releases repo for stable versions
π Debug Dependencies
View Full Tree
mvn dependency:tree
Filter Specific Dependency
mvn dependency:tree -Dincludes=com.fasterxml.jackson.core
Verbose Mode
mvn dependency:tree -Dverbose
Show Conflicts
mvn dependency:tree -Dverbose | grep "omitted for conflict"
π Force Update Dependencies
Force Maven to download latest SNAPSHOT and release versions.
mvn clean install -U
When to Use
- SNAPSHOT dependencies not updating
- Corrupted local repository
- After changing remote repository URLs
π§± Build Specific Module
Build only a specific module in a multi-module project.
mvn -pl module-name -am clean install
Flags
| Flag | Description |
|---|---|
-pl | Project list - specify module(s) |
-am | Also make - build required dependencies |
-amd | Also make dependents - build dependent modules |
Examples
# Build single module
mvn -pl service-api clean install
# Build multiple modules
mvn -pl service-api,service-impl clean install
# Build module and dependents
mvn -pl shared-utils -amd clean install
π« Skip Tests
Skip Test Execution
mvn clean install -DskipTests
Skip Compilation & Execution
mvn clean install -Dmaven.test.skip=true
Difference
skipTests: Compiles but doesnβt runmaven.test.skip: Skips everything
π§ͺ Run Specific Tests
Single Test Class
mvn -Dtest=LoginTest test
Pattern Matching
mvn -Dtest=User*Test test
Specific Test Method
mvn -Dtest=LoginTest#shouldLoginWorks test
Multiple Tests
mvn -Dtest=LoginTest,UserTest test
π§Ή Fix Corrupted Dependencies
Delete Specific Library
rm -rf ~/.m2/repository/com/oracle
Purge Entire Local Repo
mvn dependency:purge-local-repository
Re-download All
mvn dependency:purge-local-repository -DreResolve=true
π Effective POM
View the final POM after all inheritance and interpolation.
mvn help:effective-pom
Save to File
mvn help:effective-pom > effective-pom.xml
Why Use It
- Debug property resolution
- See inherited configurations
- Verify profile activation
π§ List Active Plugins
mvn help:effective-pom | grep "<plugin>"
All Available Plugins
mvn help:describe -Dplugin=compiler
π Debug Mode
Enable debug logging for CI/CD troubleshooting.
mvn clean install -X
Show Stack Traces
mvn clean install -e
π Fix SSL/Certificate Issues
Import Certificate
keytool -import -alias nexus \
-file nexus.crt \
-keystore $JAVA_HOME/jre/lib/security/cacerts \
-storepass changeit
Disable SSL Verification (Development Only)
mvn clean install -Dmaven.wagon.http.ssl.insecure=true \
-Dmaven.wagon.http.ssl.allowall=true
π§΅ Work with Profiles
List All Profiles
mvn help:all-profiles
Show Active Profiles
mvn help:active-profiles
Build with Profile
mvn clean install -Pdev
Multiple Profiles
mvn clean install -Pdev,fast-tests
π¦ Offline Mode
Download all dependencies for offline use.
mvn dependency:go-offline
Build Offline
mvn clean install -o
Use Cases
- CI/CD with dependency caching
- Development without internet
- Air-gapped environments
π― Clean Specific Targets
Clean Generated Sources
mvn clean:clean@clean-generated
Clean Without Deleting Logs
mvn clean -Dclean.exclude=logs/**
Deep Clean
mvn clean install -U -DskipTests