Javen在Maven Spring Hibernate项目中的问题 [英] Jars Issues in Maven Spring Hibernate Project
问题描述
我通过参考 Vaannila在Spring和Hibernate上创建了Web应用程序
当我使用eclipse在pom.xml中指定lib名称时,maven存储库不能包含所有的jar。
如何在应用程序中包含jar文件?
您可以使用maven 安装:安装命令,其中包括罐子到你的maven仓库中
mvn install:install-file -DgroupId = group_id -DartifactId = artifact_id -Dversion = version -Dpackaging = jar -Dfile = path_to_jar
为此,您可以尝试使用mvn包 - maven会给出一个错误,要求使用上述命令 - 复制粘贴它,更改路径并在命令提示符下使用它。
或
添加jar作为外部jar - 在Eclipse中右键单击你的项目 - 进入属性 - >构建路径 - >库 - >添加外部jar
从中央repo,将以下内容添加到您的pom中:
< repositories>
< repository>
< id>中央< / id>
< name> Maven Repository交换台< /名称>
< layout>预设< / layout>
< url> http://repo1.maven.org/maven2< / url>
<快照>
<启用> false< / enabled>
< / snapshots>
< / repository>
< / repositories>
Hibernate和Hibernate注释是独立的jar。这些是我使用的依赖关系。试试看。
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-annotations< / artifactId>
< version> 3.4.0.GA< / version>
< /依赖关系>
< dependency>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-core< / artifactId>
< version> 3.5.6-最终< / version>
< /依赖关系>
手动执行此操作,
下载hibernate-annotations from here 并保存在C:/ temp或任何你想要的地方。然后执行
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
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?
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
这篇关于Javen在Maven Spring Hibernate项目中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!