Maven - 如何为hibernate添加所有必需的依赖项? [英] Maven - how to add all required dependencies for hibernate?

查看:359
本文介绍了Maven - 如何为hibernate添加所有必需的依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从Hibernate网站下载了zip文件,我们有一个包含所有必需罐子的文件夹。



但我想和Maven一起使用。我是否需要检查哪个是此Hibernate版本所需的库并在 pom.xml中手动添加



<有没有办法只添加hibernate和maven来自己添加所有必需的库?

解决方案

如果你想使用JPA使用Hibernate,您只需要一个Maven依赖项。请参阅下载页面

 < dependency> 
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-entitymanager< / artifactId>
< version> 5.0.2.Final< / version>
< / dependency>

此依赖项将所有必需的其他工件作为传递依赖项(如JPA API,Hibernate Core和很多其他人。)



这是Maven的力量。您不需要手动向类路径添加任何内容,也不需要自己确定应添加哪些jar。一个Maven依赖项将声明为传递依赖项所需的一切。


I have downloaded the zip from the Hibernate website and we have a folder which contains all required jars.

But I want to to this with Maven. Do I need to check which are the required libraries for this Hibernate version and add them manually in the pom.xml?

Is there a way just to add hibernate and maven to add all required libraries itself?

解决方案

If you want to use JPA with Hibernate, you only need a single Maven dependency. Refer to the download page:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.0.2.Final</version>
</dependency>

This dependency will pull all the required other artifacts as transitive dependencies (like the JPA API, Hibernate Core and a lot of others).

This is the power of Maven. You don't need to add anything manually to the classpath or figure out yourself which jars you should add. One Maven dependency will declare as transitive dependencies everything that it needs.

这篇关于Maven - 如何为hibernate添加所有必需的依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆