我是hibernate的新手,并且一直试图从命令行(windows)运行SchemaExport hdm2ddl工具:
java -cp "lib/*" org.hibernate.tool.hbm2ddl.SchemaExport --config=src/hibernate.cfg.xml --create src/hello/Message.hbm.xml
我的目录结构如下:
- HelloWorld
- bin
- lib (all of the required jars - list omitted for brevity)
- src
- hello (HelloWorld.java, Message.java & Message.hbm.xml)
- persistence (HibernateUtil.java)
- hibernate.cfg.xml
- log4j.properties
尝试运行该命令会产生以下错误:
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.hibernate.internal.util.config.ConfigurationException: Could not locate cfg.xml resource [src/hibernate.cfg.xml]
at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:53)
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163)
at org.hibernate.tool.hbm2ddl.SchemaExport.buildStandardServiceRegistry(SchemaExport.java:579)
at org.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:546)
到目前为止我的研究:
这基本上是“Java Persistence with Hibernate”中的示例,但是从命令行运行它而不是使用ant。