Skip to main content

Questions tagged [maven-2]

Apache Maven is a software project management and comprehension tool. This is a tag for Maven related questions that are specific to Maven versions 2.x.

Filter by
Sorted by
Tagged with
2909 votes
33 answers
2.0m views

How can I create an executable/runnable JAR with dependencies using Maven?

I want to package my project in a single executable JAR for distribution. How can I make a Maven project package all dependency JARs into my output JAR?
soemirno's user avatar
  • 29.6k
906 votes
12 answers
766k views

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

In Maven, dependencies are usually set up like this: <dependency> <groupId>wonderful-inc</groupId> <artifactId>dream-library</artifactId> <version>1.2.3</...
Anders Sandvig's user avatar
746 votes
24 answers
458k views

Can I add jars to Maven 2 build classpath without installing them?

Maven 2 is driving me crazy during the experimentation / quick and dirty mock-up phase of development. I have a pom.xml file that defines the dependencies for the web-app framework I want to use, and ...
user avatar
716 votes
14 answers
504k views

Run a single test method with maven

I know you can run all the tests in a certain class using: mvn test -Dtest=classname But I want to run an individual method and -Dtest=classname.methodname doesn't seem to work.
BillMan's user avatar
  • 9,754
575 votes
7 answers
423k views

Maven Modules + Building a Single Specific Module

I have a multi-module Maven project with a parent project P and three sub-modules A, B, and C. Both B and C are war projects and both depend on A. I can type mvn compile in P and have all of the ...
Brian Ferris's user avatar
  • 7,817
519 votes
7 answers
377k views

How can I configure encoding in Maven?

When I run maven install on my multi-module Maven project I always get the following output: [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! ...
Ethan Leroy's user avatar
  • 16.2k
450 votes
16 answers
653k views

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...
racer's user avatar
  • 4,587
389 votes
4 answers
634k views

Maven: Command to update repository after adding dependency to POM

I've added a new dependency to my POM. Is there a simple command I can run to download this dependency to my repository?
DJ180's user avatar
  • 19.5k
383 votes
7 answers
443k views

Maven command to determine which settings.xml file Maven is using

How do I use maven command line to determine which settings.xml file Maven is picking up?
harschware's user avatar
  • 13.3k
361 votes
8 answers
245k views

Is there a simple way to remove unused dependencies from a maven pom.xml?

I have a large Maven project with many modules and many pom.xml files. The project has changed and I suspect the pom's contain some unnecessary dependencies. Is there is a command which removes any ...
user avatar
360 votes
5 answers
382k views

Maven artifact and groupId naming

I'm currently in the process of moving some project from Ant to Maven. Conformist as I am, I want to use well-established conventions for finding groupId and artifactId, but I can't find any detailed ...
Noarth's user avatar
  • 4,071
320 votes
5 answers
209k views

Making Maven run all tests, even when some fail

I have a project with several modules. When all tests pass, Maven test runs them all. When tests fail in the first module, maven will not continue to the next project. I have testFailureIgnore set to ...
ripper234's user avatar
  • 228k
310 votes
10 answers
700k views

How to get a dependency tree for an artifact?

dependency:tree can be used to see the dependency tree for a given project. But what I need is to see the dependency tree for a 3rd party artifact. I guess I can create an empty project, but I'm ...
IttayD's user avatar
  • 28.9k
309 votes
21 answers
545k views

SLF4J: Class path contains multiple SLF4J bindings

I'm getting the following error. It seems there are multiple logging frameworks bound to slf4j. Not sure how to resolve this. Any help is greatly appreciated. SLF4J: Class path contains multiple SLF4J ...
user1493140's user avatar
  • 6,106
308 votes
22 answers
482k views

Find Oracle JDBC driver in Maven repository

I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14. In MVNrepository site the dependency to put in the POM is: <dependency> <groupId>com.oracle&...
rperez's user avatar
  • 8,490
302 votes
16 answers
355k views

Make Maven to copy dependencies into target/lib

How do I get my project's runtime dependencies copied into the target/lib folder? As it is right now, after mvn clean install the target folder contains only my project's jar, but none of the ...
Michael's user avatar
  • 3,149
298 votes
2 answers
357k views

run main class of Maven project [duplicate]

I've created a simple console Java application that is built with Maven. Is there a way that the main class (which doesn't require any arguments) can be run from the command-line using a maven command ...
Dónal's user avatar
  • 186k
297 votes
4 answers
162k views

Maven parent pom vs modules pom

There seem to be several ways to structure parent poms in a multiproject build and I wondering if anyone had any thoughts on what the advantages / drawbacks are in each way. The simplest method of ...
Jamie McCrindle's user avatar
289 votes
34 answers
230k views

How to get Maven project version to the bash command line

Previous I issued a question on how to change Maven project vesion from command line which lead me to a new issue. Previously I was able to get the version number since the version was stored as a ...
mkko's user avatar
  • 4,392
273 votes
12 answers
311k views

Exclude all transitive dependencies of a single dependency

In Maven2, to exclude a single transitive dependency, I have to do something like this: <dependency> <groupId>sample.group</groupId> <artifactId>sample-artifactB</...
pbreault's user avatar
  • 14.4k
271 votes
10 answers
410k views

Maven: add a dependency to a jar by relative path

I have a proprietary jar that I want to add to my pom as a dependency. But I don't want to add it to a repository. The reason is that I want my usual maven commands such as mvn compile, etc, to work ...
flybywire's user avatar
  • 269k
271 votes
7 answers
170k views

Build Maven Project Without Running Unit Tests

How do you build a Maven project without running unit tests? Currently restructuring some code I have for a Servlet and would like to try it out in my web browser (which means running mvn install to ...
Federer's user avatar
  • 34.3k
260 votes
9 answers
289k views

Convert Existing Eclipse Project to Maven Project

For a project at work, we're considering using the Maven plugin for Eclipse to automate our builds. Right now the procedure is far more complicated than it ought to be, and we're hoping that Maven ...
Thorn G's user avatar
  • 12.7k
247 votes
14 answers
295k views

How can I download a specific Maven artifact in one command line?

I can install an artifact by install:install-file, but how can I download an artifact? For example: mvn download:download-file -DgroupId=.. -DartifactId=.. -Dversion=LATEST
Lenik's user avatar
  • 14.3k
237 votes
11 answers
304k views

Maven dependency for Servlet 3.0 API?

How can I tell Maven 2 to load the Servlet 3.0 API? I tried: <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version&...
deamon's user avatar
  • 91.3k
236 votes
10 answers
449k views

Controlling Maven final name of jar artifact

I'm trying to define a property in our super pom which will be used by all child projects as the destination of the generated artifact. For this I was thinking about using project/build/finalName yet ...
Maxim Veksler's user avatar
218 votes
4 answers
139k views

Maven: how to do parallel builds?

When you build with maven on a multicore / multi-CPU machine it would often be possible to build different subprojects in parallel. Is there a way to do this with maven? Is there a plugin for this / ...
Dr. Hans-Peter Störr's user avatar
217 votes
10 answers
200k views

Maven compile with multiple src directories

Is there a way to compile multiple java source directories in a single maven project?
sal's user avatar
  • 23.5k
215 votes
14 answers
357k views

Best practices for copying files with Maven

I have config files and various documents that I want to copy from the dev environment to the dev-server directory using Maven2. Strangely, Maven does not seem strong at this task. Some of the ...
Joshua Fox's user avatar
  • 19.4k
215 votes
13 answers
112k views

What causes imported Maven project in Eclipse to use Java 1.5 instead of Java 1.6 by default and how can I ensure it doesn't?

I imported a Maven project and it used Java 1.5 even though I have 1.6 configured as my Eclipse default Preferences->Java->Installed JREs. When I changed the Maven project to use the 1.6 JRE ...
Chris Collins's user avatar
212 votes
8 answers
82k views

Maven check for updated dependencies in repository

Is there a Maven plugin that allows you to check if there are newer versions of dependencies available in the repository? Say, you are using dependency X with version 1.2. Now a new version of X is ...
froethen's user avatar
  • 2,133
210 votes
10 answers
311k views

How do I get my Maven Integration tests to run

I have a maven2 multi-module project and in each of my child modules I have JUnit tests that are named Test.java and Integration.java for unit tests and integration tests respectively. When I execute:...
Peter Delaney's user avatar
203 votes
5 answers
72k views

Sharing Test code in Maven

How can you depend on test code from another module in Maven? Example, I have 2 modules: Base Main I would like a test case in Main to extend a base test class in Base. Is this possible? Update:...
flicken's user avatar
  • 15.5k
202 votes
13 answers
179k views

Get Maven artifact version at runtime

I have noticed that in a Maven artifact's JAR, the project.version attribute is included in two files: META-INF/maven/${groupId}/${artifactId}/pom.properties META-INF/maven/${groupId}/${artifactId}/...
Armand's user avatar
  • 24k
198 votes
4 answers
130k views

Disable a Maven plugin defined in a parent POM

I am using a parent POM that defines a plugin that I do not want to be run in a child POM. How can I disable the plugin in the child pom completely? Constraint: I cannot change the parent POM itself.
tobiasbayer's user avatar
  • 10.3k
197 votes
13 answers
352k views

Force re-download of release dependency using Maven

I'm working on a project with dependency X. X, in turn, depends on Y. I used to explicitly include Y in my project's pom. However, it was not used and to make things cleaner, I instead added it to X'...
volni's user avatar
  • 5,286
192 votes
15 answers
434k views

Specify JDK for Maven to use

I am trying to build a Hudson plugin I've modified and it requires jdk1.6. This is fine, but I don't see how I can tell maven where the different jdk is. I've found few mentions on the internet but ...
DanInDC's user avatar
  • 5,139
190 votes
8 answers
395k views

Importing Maven project into Eclipse

I want to import existing Maven project into Eclipse. I found 2 ways to do it: Through running from command line mvn eclipse:eclipse To install Maven Eclipse plugin from Eclipse. What is the ...
Thunderhashy's user avatar
  • 5,311
189 votes
11 answers
205k views

How to change maven logging level to display only warning and errors?

I want to prevent maven from displaying INFO messages, I want to see only WARNINGS and ERRORS (if any). How can I achieve this, preferably by changing the command line that calls maven?
sorin's user avatar
  • 167k
188 votes
18 answers
170k views

Get source jar files attached to Eclipse for Maven-managed dependencies

I am using Maven (and the Maven Eclipse Integration) to manage the dependencies for my Java projects in Eclipse. The automatic download feature for JAR files from the Maven repositories is a real time ...
Thilo's user avatar
  • 261k
187 votes
9 answers
190k views

Differences between Ant and Maven [closed]

Could someone tell me the differences between Ant and Maven? I have never used either. I understand that they are used to automate the building of Java projects, but I do not know where to start from.
user avatar
186 votes
5 answers
289k views

Maven: how to override the dependency added by a library

Here's my generic problem: My project P depends on A which depends on B which depends on C which depends on version 1.0.1 of D. There's a problem with version 1.0.1 of D and I want to force the use of ...
wishihadabettername's user avatar
183 votes
16 answers
379k views

Maven: best way of linking custom external JAR to my project?

It's my first couple of days learning Maven and I'm still struggling with the basics. I have an external .jar file (not available in the public repos) that I need to reference in my project and I'm ...
Alexandr Kurilin's user avatar
181 votes
15 answers
166k views

Spring 3.0 - Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]

Any ideas what could be the cause of this? Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] org.springframework.web.context....
Taylor Leese's user avatar
  • 51.8k
170 votes
12 answers
247k views

Is there anyway to exclude artifacts inherited from a parent POM?

Artifacts from dependencies can be excluded by declaring an <exclusions> element inside a <dependency> But in this case it's needed to exclude an artifact inherited from a parent project. ...
Miguel's user avatar
  • 2,109
169 votes
2 answers
193k views

mvn clean install vs. deploy vs. release

I am just learning maven, and we have recently needed to go more and more. I would like to know the difference between mvn clean install mvn release mvn deploy Please be as descriptive as possible.
Mahdi Yusuf's user avatar
  • 20.7k
168 votes
6 answers
103k views

Is it possible to rename a maven jar-with-dependencies?

I'm currently using the jar-with-dependencies assembly to create such a jar. However, the name of my jar is a bit long. Since this jar is being used by RPG programs on an AS400, I'd like to ...
Mike Cornell's user avatar
  • 6,009
160 votes
4 answers
420k views

Sample settings.xml

How to configure settings.xml in Maven? Also, please share a sample settings.xml!
brindha's user avatar
  • 1,617
156 votes
14 answers
213k views

Unable to use Intellij with a generated sources folder

Related question How to configure IntelliJ IDEA and/or Maven to automatically add directories with Java source code generated using jaxb2-maven-plugin? I have a custom plugin that generates sources ...
Kannan Ekanath's user avatar
153 votes
12 answers
249k views

Warning - Build path specifies execution environment J2SE-1.4

I create a Maven project in Eclipse Helios. It works fine for a day, but then this warning shows up: Build path specifies execution environment J2SE-1.4. There are no JREs installed in the ...
narsereg's user avatar
  • 1,553

1
2 3 4 5
114