How-to articles, tricks, and solutions about MAVEN

Create a Maven project in Eclipse complains "Could not resolve archetype"

There could be several reasons why you are getting the error "Could not resolve archetype" when trying to create a Maven project in Eclipse.

How do I load a file from resource folder?

To load a file from the resource folder in a Java application, you can use the ClassLoader and getResourceAsStream method.

How do I tell Maven to use the latest version of a dependency?

To tell Maven to use the latest version of a dependency, you can use the [RELEASE] or [LATEST] version range in the <version> element of the dependency in your pom.xml file.

How to add local jar files to a Maven project?

To add a local JAR file to a Maven project, you can use the maven-install-plugin. Here's how you can do it:

How to set specific Java version to Maven?

To set a specific Java version for Maven, you can specify the maven.compiler.source and maven.compiler.target properties in the pom.xml file.

Import Maven dependencies in IntelliJ IDEA

To import Maven dependencies in IntelliJ IDEA, you can follow these steps:

IntelliJ inspection gives "Cannot resolve symbol" but still compiles code

There are a few possible reasons why IntelliJ might show a "Cannot resolve symbol" error while still being able to compile your code.

Maven package/install without test (skip tests)

To package/install a Maven project without running the tests, you can use the maven-install-plugin and specify the skipTests property as true.

Maven plugins can not be found in IntelliJ

There are several possible reasons why Maven plugins might not be found in IntelliJ:

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

This error message means that the Java compiler (javac) is not available in the current environment. This can happen if you are running a Java program from a Java Runtime Environment (JRE) rather than a Java Development Kit (JDK).

Run a single test method with maven

To run a single test method with Maven, you can use the surefire:test goal and specify the fully-qualified name of the test class and the method name using the test and method properties, respectively.

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

This error typically occurs when you are trying to use the HttpServlet class in a Java project, but the necessary libraries are not included in the project's classpath. To fix this error, you need to add the servlet-api.jar library to your project's class

What exactly is a Maven Snapshot and why do we need it?

A Maven snapshot is a version of a Maven artifact that is under active development and has not been released yet.