首页 新闻 会员 周边 捐助

hibernate官网上的 例子 出现的 问题 maven compile

0
[已关闭问题] 关闭于 2013-12-27 17:07

最近在 研究 hibernate ,按照 官网的 例子 我动手开始研究 maven ,但是 在 compile 的时候 居然 报错了

[ERROR]     'dependencies.dependency.version' for org.hibernate:hibernate-core:jar is missing. @ line 18, column 15
[ERROR]     'dependencies.dependency.version' for javax.servlet:servlet-api:jar is missing. @ line 25, column 15
[ERROR]     'dependencies.dependency.version' for org.slf4j:slf4j-simple:jar is missing. @ line 32, column 15
[ERROR]     'dependencies.dependency.version' for javassist:javassist:jar is missing. @ line 39, column 15

 

从错误信息判断,是因为jar包没有 找到

hibernate-core:jar

servlet-api:jar

slf4j-simple:jar

javassist:jar

但是我记得 maven 是自动导入jar 的啊

还有 那个 javassist 也是 jar 嘛

小四儿的主页 小四儿 | 菜鸟二级 | 园豆:230
提问于:2013-12-27 17:00
< >
分享
所有回答(1)
0

转自:http://tonado.blogbus.com/logs/42492456.html

如果跟着教程一步一步做的话,做到mvn compile那一步会报错

[0] 'dependencies.dependency.version' is missing for org.hibernate:hibernate-core:jar
[1] 'dependencies.dependency.version' is missing for javax.servlet:servlet-api:jar
[2] 'dependencies.dependency.version' is missing for org.slf4j:slf4j-simple:jar
[3] 'dependencies.dependency.version' is missing for javassist:javassist:jar

 

教程里的pom.xml显然不全,缺少version,通过查看maven repository http://mvnrepository.com/ 找version信息可得修正版的pom.xml如下:

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hibernate.tutorials</groupId>
<artifactId>hibernate-tutorial</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>First hibernate tutorials</name>
<url>http://maven.apache.org</url>
<dependencies>
   <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>3.3.2.GA</version>
   </dependency>
   <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>[2.4,)</version>      
   </dependency>
   <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.5.6</version>
   </dependency>
   <dependency>
      <groupId>javassist</groupId>
      <artifactId>javassist</artifactId>
      <version>[3.0,)</version>
   </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
   <finalName>${artifactId}</finalName>
</build>
</project>

小四儿 | 园豆:230 (菜鸟二级) | 2013-12-27 17:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册