Search code examples
hibernatespringspring-mvcmaven-3m2eclipse

Jars Issues in Maven Spring Hibernate Project


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?


Solution

  • 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