标签:maven hibernate3 hbm2ddl jdk 1.7 configurationtask
问题描述:
进入simple-webapp目录下运行
mvn hibernate3:hbm2ddl
报如下错误
[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.1:hbm2ddl (default-cli) on project simple-webapp: Could not get ConfigurationTask. -> [Help 1]
我的环境如下:
jdk1.7,maven V3.3.1
C:\Users\xiaopan\simple-parent-spring\simple-parent\simple-webapp>mvn -v Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-14T04:10:27+08:00) Maven home: C:\DevelopTools\maven\bin\.. Java version: 1.7.0_40, vendor: Oracle Corporation Java home: C:\home\jdk\jdk 1.7.40\jre Default locale: zh_CN, platform encoding: GBK OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
报错原因:
根据http://stackoverflow.com/questions/23270551/maven-by-example-nullpointer-executing-hibernate3hbm2ddl 的解答,根据答案内容可以得出是jdk1.7版本导致,需要降级到1.6
问题描述:
于是我将jdk降级到1.6,此时出现了另一个报错
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) ...
报错原因:
看上去像jdk版本错误导致,于是查了谷歌,根据http://stackoverflow.com/questions/29255495/maven-installation-osx-error-unsupported-major-minor-version-51-0 的回答以及回答中指向的 https://jira.codehaus.org/browse/MNG-5780 链接可以得出:
maven在V3.3.1版本后对jdk最低要求1.7版本,而我现在降级到了1.6版本所以报错
解决方案:
降级maven到V3.2.5版本
降级后环境变量如下jdk1.6、maven V3.2.5
C:\Users\xiaopan>mvn -v Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T01:29:23+08:00) Maven home: C:\DevelopTools\maven\bin\.. Java version: 1.6.0_38, vendor: Sun Microsystems Inc. Java home: C:\home\jdk\jdk 1.6.38\jre Default locale: zh_CN, platform encoding: GBK OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
进入simple-webapp重新运行mvn hibernate3:hbm2ddl,
成功!
maven权威指南7.7节使用Hibernate3插件构造数据库报错
标签:maven hibernate3 hbm2ddl jdk 1.7 configurationtask
原文地址:http://pan2624.blog.51cto.com/7148851/1635855