Maven, isnt faster to download the .jars yourself?

I understand the benefits of Maven, but if i have to configure pom.xml, then isn't it more difficult than the alternatives? As an example, consider the following pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mastertheboss</groupId>
    <artifactId>Hibernate4Example</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.21</version>
        </dependency>
    </dependencies>
</project>

How can I know that the artifact ID is mysql-connecto-java, and what is the version supposed to be? I have to look in the website of the MySQL JDBC driver to find this, for example. Now I need the postgresql, and I have to search on Google for "Pom.xml for postgresql". If i go to the postgresql websote, I can download the jdbc_driver.jar directly. That's faster isn't it?

How should I find this information (artifact IDs and versions) without a Google search?

Answers


how can i know this "artifactID" and "Version" without looking in the google?

I dont know what's the problem looking in google, but if you prefer and use Eclipse, just click on right button in pom.xml, Maven, Add dependency and type the name of dependency you want.

I prefer search in the google like "postgre maven dependency", in general will see http://mvnrepository.com/ direct link to your dependency in maven central repository, the most jar projects you can found in Maven Central, but you can also add others repository in the pom.xml

PostgreSQL dependency (http://mvnrepository.com/artifact/postgresql/postgresql/9.1-901.jdbc4)

<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>

you can add others repository in your pom.xml like this

    <repository>
        <id>oss.sonatype.org</id>
        <name>OSS Sonatype Staging</name>
        <url>https://oss.sonatype.org/content/groups/staging</url>
    </repository>

Version dependency

<properties>
    <java-version>1.6</java-version>
    <org.springframework-version>4.0.0.RELEASE</org.springframework-version>
    <mysql.version>5.1.27</mysql.version>
</properties>

Using dependency with version defined above

 <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${org.springframework-version}</version>
        <scope>test</scope>
    </dependency>


   <!-- MySQL -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${mysql.version}</version>
    </dependency>

Using properties, you can change dependency version in just one place

Maven is very usefull management dependency, and more, you can add build features to your project.


You can simply search on the Maven Central Repository.


Need Your Help

Setting dynamic fallback in jquery each with JSON data

javascript jquery json ajax jsonp

I am trying to set a fallback function dynamically from an ajax jsonp call, but it doesn't seem to work - I am actually not quite sure if it is even possible - at least I believe I am doing it wro...

TFS 2010 - TF14040 The Folder may not be checked out

asp.net visual-studio-2010 tfs tfs2010

I have a .NET 4 website in VS2010 stored in a TFS 2010 team project. I need to add a reference to System.Data.Linq.dll to the website. I am referencing a LINQ DataContext that is defined in another