Maven Spring Hibernate 项目中的 Jars 问题

发布于 2024-12-25 02:34:33 字数 209 浏览 1 评论 0原文

我参考 Vaannila

当我使用 eclipse 在 pom.xml 上指定 lib 名称时,maven 存储库无法包含所有 jar。

如何将这些 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谈情不如逗狗 2025-01-01 02:34:33

你可以使用maven install:install 命令它将 jar 包含到您的 Maven 存储库中

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

为此,你可以尝试 mvn package - maven 会给出一个错误,要求使用上面的命令 - 复制粘贴它,更改路径并在命令提示符中使用它。

将 jar 添加为外部 jar - 在 Eclipse 中右键单击您的项目 - 转到属性 --> 构建路径 --> 库 --> 添加外部 jar

要从中央存储库下载,请将以下内容添加到您的 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 和 Hibernate 注释是单独的 jar。这些是我使用的依赖项。尝试一下。

    <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>

要手动执行此操作,

请从 此处并将其保存在 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。罐

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

夏日浅笑〃 2025-01-01 02:34:33

请参阅此 Maven Spring Hibernate 示例项目

希望您能从那里轻松理解。

See this Maven Spring Hibernate example project.

Hopefully you will easily understand from there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文