0

I had made Web Application on Spring and Hibernate by taking reference from Vaannila

When I specify lib name on pom.xml using eclipse, the maven repository could not include all the jars.

How can I include the jars on my application?

Ankit
  • 425
  • 1
  • 5
  • 21

2 Answers2

2

you could use the maven install:install command which includes the jars into your maven repo

mvn install:install-file -DgroupId=group_id -DartifactId=artifact_id -Dversion=version -Dpackaging=jar -Dfile=path_to_jar

For this , you could try mvn package - maven will given an error asking use to use the above command - copy paste it , change the path and use it in your command prompt .

or

add the jar as an external jar - Right click your project in Eclipse - go to properties -->Build path -->Libraries -->Add external jars

To download from the central repo ,add the following to your pom

<repositories>
 <repository>
  <id>central</id>
  <name>Maven Repository Switchboard</name>
  <layout>default</layout>
  <url>http://repo1.maven.org/maven2</url>
  <snapshots>
    <enabled>false</enabled>
  </snapshots>
 </repository>
</repositories>

Hibernate and Hibernate annotations are separate jars . These are the dependencies I use . Try them .

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.4.0.GA</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.5.6-Final</version>
    </dependency>

To do this manually ,

Download hibernate-annotations from here and save it in C:/temp or wherever you want. Then perform

mvn install:install-file -DgroupId=org.hibernate -DartifactId=hibernate-annotations -Dversion=3.4.0.GA -Dpackaging=jar -Dfile=C:/temp/hibernate-annotations-3.4.0.GA.jar

Aravind A
  • 9,507
  • 4
  • 36
  • 45
  • Still, I had to specify the dependency details on pom.xml. My problem is after including the dependency, I am facing error 'java.lang.NoClassDefFoundError: org/hibernate/annotations/Entity' – Ankit Jan 03 '12 at 07:39
  • 1
    Do you have the hibernate annotations jar in your .m2 folder ? If not , include it using the install:install command . To access this dependency in your project using maven , you'll have to include it in your pom . – Aravind A Jan 03 '12 at 07:50
  • hibernate3.jar comes from hibernate distribution but this jar could not loaded in maven repository. kindly suggest. – Ankit Jan 03 '12 at 09:06
  • See my edit . Also do an mvn eclipse:eclipse to bring this into the classpath if it does not happen automatically. – Aravind A Jan 03 '12 at 10:16
0

See this Maven Spring Hibernate example project.

Hopefully you will easily understand from there.

Warren Sergent
  • 2,542
  • 4
  • 36
  • 42