Ankit Sharma
Ankit Sharma

Reputation: 147

Maven depedency not working in primefaces?

I wanted to show the barcode in primefcaes.For that i created a maven based project & added two dependency for those libararies such as

<dependency>
    <groupId>net.glxn</groupId>
    <artifactId>qrgen</artifactId>
    <version>1.4</version>
</dependency>
<dependency>
    <groupId>net.sf.barcode4j</groupId>
    <artifactId>barcode4j-light</artifactId>
    <version>2.1</version>
</dependency>

I read in primefaces documentation that barcode4j-2.1 may not be available in maven so i need to manual install the jar in maven repo

I have installed the jar into maven repo using this command in eclipse

install:install-file -Dfile=D:\qrgen-1.4.jar -DgroupId=net.glxn -DartifactId=qrgen -Dversion=1.4 -Dpackaging=jar

 install:install-file -Dfile=D:\barcode4j-light-2.1.jar -DgroupId=net.sf.barcode4j -DartifactId=barcode4j-light -Dversion=2.1 -Dpackaging=jar

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>com.prime</groupId>
    <artifactId>primedemop</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>primefaces</name>
    <dependencies>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>5.1</version>
        </dependency>
        <dependency>
            <groupId>net.glxn</groupId>
            <artifactId>qrgen</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>net.sf.barcode4j</groupId>
            <artifactId>barcode4j-light</artifactId>
            <version>2.1</version>
        </dependency>
    </dependencies>
</project>

But i can't see any barcode generated if i was adding the barcode4j-light-2.1 jar file in lib folder then i was able to generate bar code but not the QR code but now i can't generate not even barcode.

I get the following output on eclipse console when i install the jar file into maven repo.

For qrgen jar

pic1 for barcode4j pic2

Upvotes: 1

Views: 1196

Answers (1)

Ryan J
Ryan J

Reputation: 8323

Look at the groupId and artifactId's for your dependencies and what you installed:

qrgen:       -DgroupId=net.glxn.qrgen -DartifactId=qrgen
qrgen-light: -DgroupId=net.glxn.qrgen -DartifactId=qrgen

Your dependencies show a different group/artifactId:

<dependency>
    <groupId>net.glxn</groupId>                 <--- here
    <artifactId>qrgen</artifactId>              <--- here
    <version>1.4</version>
</dependency>
<dependency>
    <groupId>net.sf.barcode4j</groupId>         <--- here
    <artifactId>barcode4j-light</artifactId>    <--- here
    <version>2.1</version>
</dependency>

You manually installed your jars to a directory in the maven repo called net/glxn/qrgen/qrgen but your dependencies are expecting to find them in net/glxn/qrgen and net/sf/barcode4j/barcode4j-light respectively.

You need to update your manual install commands to:

install:install-file -Dfile=D:\qrgen-1.4.jar -DgroupId=net.glxn -DartifactId=qrgen -Dversion=1.4 -Dpackaging=jar

and

install:install-file -Dfile=D:\barcode4j-light-2.1.jar -DgroupId=net.sf.barcode4j -DartifactId=barcode4j-light -Dversion=1.4 -Dpackaging=jar

Upvotes: 2

Related Questions