我一直在关注http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html上的休眠教程
正如其他人在各种网络板上指出的那样,它是不完整的。当我运行这个命令时:
mvn exec:java -Dexec.mainClass="org.hibernate.tutorial.EventManager" -Dexec.args="store"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ hibernate-tutorial >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ hibernate-tutorial <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ hibernate-tutorial ---
[WARNING]
java.lang.ClassNotFoundException: org.hibernate.tutorial.EventManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:722)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.962s
[INFO] Finished at: Sun Sep 30 17:03:34 EDT 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (d
efault-cli) on project hibernate-tutorial: An exception occured while executing
the Java class. org.hibernate.tutorial.EventManager -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
所以我认为问题很明显。当maven执行java时,java不知道在哪里可以找到我的'EventManager'。我在命令行上尝试了以下操作:
设置 CLASSPATH=C:\Users\robe\Documents\hibernate\project1\src\main\java\org
这里还有什么问题?
谢谢!