Jars Issues in Maven Spring Hibernate Project

可紊 提交于 2020-01-07 02:06:05

问题


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?


回答1:


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




回答2:


See this Maven Spring Hibernate example project.

Hopefully you will easily understand from there.



来源:https://stackoverflow.com/questions/8708416/jars-issues-in-maven-spring-hibernate-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!