简体   繁体   中英

How to manage project dependencies using Maven?

This is probably a newbie quesiton, but I'm a newbie when it comes to Java and the Maven documentation is tough to work through and all seems to be written for Maven experts. I'm trying to install a driver in a Java project. I've got a project with code that works (ie, I don't want to torch what I already have) and maven is installed and up-to-date. I know the dependency XML to add to pom.xml, but I don't know where to start to create a pom.xml file.

I tried to run 'mvn install' a couple of times, but I don't see the driver anywhere so I can't reference it with my java build path.

What's the best way to proceed?

First of all check if the maven is installed - mvn --version in the command line.

If not - follow the guide - http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

To create a pom.xml manually is not a good point if you use IDE - just create a new Maven project (for example in Idea or Eclipse). This way you will avoid errors with some required configurational tags missing. Then add the needed dependency in the dependencies tag in pom.xml

Actually, one of the best tutorials about maven is http://www.mkyong.com/tutorials/maven-tutorials/ - there are a lot of topics. Choose the desired one.

If you use Eclipse IDE just follow this tutorial to convert your project to the Maven project - Convert Existing Eclipse Project to Maven Project - and delete the pom.xml created by you before that. Be sure to have the m2eclipse plugin installed in the IDE.

This is for the conversion in the Intellij idea - IntelliJ - Convert a Java project/module into a Maven project/module

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM