- Maven Essentials
- Prabath Siriwardena
- 504字
- 2021-07-30 10:11:28
Troubleshooting
If everything works fine, we should never have to worry about troubleshooting. However, most of the time this is not the case. A Maven build can fail for many reasons, some of which are under your control and also out of your control. Knowing proper troubleshooting tips helps you to pinpoint the exact problem. The following section lists some of the most used troubleshooting tips. We will expand the list as we proceed in this book.
Enabling Maven debug level logs
Once the Maven debug level logging is enabled, it will print all the actions that it takes during the build process. To enable debug level logging, use the following command:
$ mvn clean install –X
Building a dependency tree
If you find any issue with any dependency in your Maven project, the first step is to build a dependency tree. This shows where each dependency comes from. To build the dependency tree, run the following command against your project POM
file:
$ mvn dependency:tree
The following shows the truncated output of the previous command executed against the Apache Rampart project:
[INFO] -------------------------------------------------------------- [INFO] Building Rampart - Trust 1.6.1-wso2v12 [INFO] -------------------------------------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ rampart-trust --- [INFO] org.apache.rampart:rampart-trust:jar:1.6.1-wso2v12 [INFO] +- org.apache.rampart:rampart-policy:jar:1.6.1-wso2v12:compile [INFO] +- org.apache.axis2:axis2-kernel:jar:1.6.1-wso2v10:compile [INFO] | +- org.apache.ws.commons.axiom:axiom-api:jar:1.2.11-wso2v4:compile (version managed from 1.2.11) [INFO] | | \- jaxen:jaxen:jar:1.1.1:compile [INFO] | +- org.apache.ws.commons.axiom:axiom-impl:jar:1.2.11-wso2v4:compile (version managed from 1.2.11) [INFO] | +- org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:jar:1.1.2:compile [INFO] | +- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1:compile [INFO] | +- javax.servlet:servlet-api:jar:2.3:compile [INFO] | +- commons-httpclient:commons-httpclient:jar:3.1:compile [INFO] | | \- commons-codec:commons-codec:jar:1.2:compile [INFO] | +- commons-fileupload:commons-fileupload:jar:1.2:compile
Viewing all the environment variables and system properties
If you have multiple JDKs installed in your system, you may wonder what is being used by Maven. The following command will display all the environment variables and system properties set for a given Maven project:
$ mvn help:system
The following is the truncated output of the previous command:
======================Platform Properties Details==================== ===================================================================== System Properties ===================================================================== java.runtime.name=Java(TM) SE Runtime Environment sun.boot.library.path= /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib java.vm.version= 24.75-b04 awt.nativeDoubleBuffering=true gopherProxySet=false mrj.build=11M4609 java.vm.vendor=Apple Inc. java.vendor.url=http://www.apple.com/ guice.disable.misplaced.annotation.check=true path.separator=: java.vm.name=Java HotSpot(TM) 64-Bit Server VM file.encoding.pkg=sun.io sun.java.launcher=SUN_STANDARD user.country=US sun.os.patch.level=unknown ======================================================== Environment Variables ======================================================== JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home HOME=/Users/prabath TERM_SESSION_ID=C2CEFB58-4705-4C67-BE1F-9E4179F96391 M2_HOME=/usr/share/maven/maven-3.3.3/ COMMAND_MODE=unix2003 Apple_PubSub_Socket_Render=/tmp/launch-w7NZbG/Render LOGNAME=prabath USER=prabath
Viewing the effective POM file
Maven uses default values for configuration parameters when they are not overridden in the configuration. This is exactly what we discussed under the Convention over configuration section. If we take the same sample POM
file that we used before in this chapter, we can see how the effective POM
file would look using the following command. This is also the best way to see what default values are being used by Maven:
$ mvn help:effective-pom
Note
More details about the effective-pom
command are discussed in Chapter 2, Understanding the Project Object Model (POM).
Viewing the dependency classpath
The following command will list all the JAR files and directories in the build classpath
:
$ mvn dependency:build-classpath
The following shows the truncated output of the previous command executed against the Apache Rampart project:
[INFO] -------------------------------------------------------------- [INFO] Building Rampart - Trust 1.6.1-wso2v12 [INFO] -------------------------------------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.1:build-classpath (default-cli) @ rampart-trust --- [INFO] Dependencies classpath: /Users/prabath/.m2/repository/bouncycastle/bcprov-jdk14/140/bcprov-jdk14-140.jar:/Users/prabath/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar:/Users/prabath/.m2/repository/commons-codec/commons-codec/1.2/commons-codec-1.2.jar:/Users/prabath/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar
- Puppet 4 Essentials(Second Edition)
- Instant Node Package Manager
- Java程序設計與開發
- Learning Cython Programming
- Developing Middleware in Java EE 8
- Elasticsearch for Hadoop
- Elasticsearch Essentials
- 編程改變生活:用Python提升你的能力(進階篇·微課視頻版)
- Python期貨量化交易實戰
- Scala Functional Programming Patterns
- Anaconda數據科學實戰
- Mastering ASP.NET Core 2.0
- ROS機器人編程實戰
- 計算機應用基礎案例教程(第二版)
- Oracle SOA Suite 12c Administrator's Guide