【问题标题】:Maven Dependency NightmareMaven 依赖噩梦
【发布时间】:2016-05-16 05:49:29
【问题描述】:

我对编程非常陌生,并且正在学习包含使用 Maven 的 Hibernate 教程。在我尝试使用教程中推荐的命令 mvn 编译或启动我的 HSQLDB 服务器之前,一切似乎都很顺利:

mvn exec:java -Dexec.mainClass="org.hsqldb.Server" -Dexec.args="-database.0 file:target/data/tutorial"

那时我遇到了构建失败,我将在下面包含我的 pom.xml 文件。它似乎告诉我依赖项缺少 pom,但我不知道如何解决这个问题。任何帮助将不胜感激,这样我就可以继续我的学习经历。

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.hibernate.tutorials</groupId>
<artifactId>hibernate-tutorial</artifactId>
<version>1.0.0-snapshot</version>
<name>First Hibernate Tutorial</name>

<build>
     <!-- we dont want the version to be part of the generated war file name -->
     <finalName>${project.artifactId}</finalName>
</build>

<dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.0.7.final</version>
    </dependency>

    <!-- Because this is a web app, we also have a dependency on the servlet api. -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>

    <!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.14</version>
    </dependency>

    <!-- Hibernate gives you a choice of bytecode providers between cglib and javassist -->
    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.18.1-GA</version>
    </dependency>
</dependencies>

【问题讨论】:

  • 请注意&lt;finalName&gt;...&lt;/finalName&gt; 仅处理本地目录target 中的名称,但不会影响通过mvn install 部署到本地存储库或远程存储库mvn deploy 中的名称....如果您在 Eclipse 之类的 IDE 中工作,那没关系...
  • 有什么选择?
  • 别无选择,因为您不需要更改名称...如果您在 exec-maven-plugin 中运行,则可以使用默认值等...

标签: java hibernate maven dependencies pom.xml


【解决方案1】:

使用search.maven.com,Hibernate 依赖名称似乎是hibernate-core-5.0.7.Final。即Final 中的大写F。所以试试

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.0.7.Final</version>
</dependency>

改为

【讨论】:

  • 我实际上并没有修复这个特定的操作,但我认为你是正确的,所以我标记为正确。多么小而重要的细节,我相信你是对的。今天早上我最终找到了一个网站,上面有一篇关于本教程中许多缺陷的帖子,这些缺陷使得它很难完成。我想这就是我们学习的方式。
猜你喜欢
  • 1970-01-01
  • 2010-12-21
  • 2020-03-14
  • 2010-11-13
  • 2010-12-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多