来自Commandline的Hibernate SchemaExport

时间:2015-11-08 14:33:29

标签: java hibernate schemaexport

我是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)

到目前为止我的研究:

  1. 该命令找不到hibernate.cfg.xml文件。将命令中文件的拼写更改为错误的拼写会产生相同的错误。
  2. 将cfg.xml文件复制到classpath(lib)和HelloWorld目录中。错误仍然存​​在。
  3. 这基本上是“Java Persistence with Hibernate”中的示例,但是从命令行运行它而不是使用ant。

0 个答案:

没有答案