0

In my jsf project. How can i add mysql libraries in maven dependency ? I am trying to copy and paste. It says i cant do. I also tried to add library in build path. it didnt work. I am using Eclipse. This is my maven tree

This is my pom.xml

<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>jsflab</groupId>
  <artifactId>jsflab</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>org.richfaces</groupId>
        <artifactId>richfaces</artifactId>
        <version>4.5.0.Final</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>


  </dependencies>
</project>
Kukeltje
  • 11,924
  • 4
  • 19
  • 44

4 Answers4

2

Add below snippet into your pom.xml

<properties>
            <mysql.version>6.0.3</mysql.version>
</properties>
<dependencies>
        <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${mysql.version}</version>
    </dependency>
</dependencies>

After this clean your project and build

To build through command prompt see this

by eclipse see this

Community
  • 1
  • 1
Venu
  • 324
  • 3
  • 15
1

Add following to your pom.xml file

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.39</version>
</dependency>

Edit: If the pom is externally updated, then we have to update the maven project in Eclipse

Package Explorer -> right click on project > Maven > Update project

sidgate
  • 11,396
  • 8
  • 53
  • 100
  • @AnılŞenocak refresh eclipse project. Package Explorer -> right click on project > Maven > Update project. Also try building the project using `mvn install` – sidgate Jul 29 '16 at 09:00
  • Thanks it worked. @sidgate Package Explorer -> right click on project > Maven > Update project. –  Jul 29 '16 at 09:05
1

In your pom.xml Add MySQL dependency :

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

You can find all Maven dependeny from here MVNRepository

Neeraj Jain
  • 7,077
  • 3
  • 26
  • 53
0

you have to run update project from maven options or you can run maven install to download the dependencies.

techprat
  • 345
  • 7
  • 23