java org.hibernate.cfg.Environment - 找不到 hibernate.properties

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4754728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 07:52:31  来源:igfitidea点击:

org.hibernate.cfg.Environment - hibernate.properties not found

javahibernategwttomcat

提问by techbeast16

I am working on a project which uses GWT on client side, Tomcat Apache server, MySQL, Hibernate with JPA. I am also using annotations and EntityManager My folder structure is as follows:

我正在开发一个在客户端使用 GWT、Tomcat Apache 服务器、MySQL、带有 JPA 的 Hibernate 的项目。我也在使用注解和EntityManager 我的文件夹结构如下:

+build
+java
   +com
   +META-INF
       persistence.xml
+webcontent
   +WEB-INF

I am getting following output in the console among other info

我在控制台中得到以下输出以及其他信息

INFO org.hibernate.cfg.Environment  - hibernate.properties not found
INFO org.hibernate.cfg.Environment  - Bytecode provider name : javassist

I also tried placing persistence.xml inside web-inf/meta-inf but I still get same error. This is happening only when I operate it on server. If I test it locally using a main class, it works. Any idea why it can not find properties file

我也尝试将 persistence.xml 放在 web-inf/meta-inf 中,但我仍然遇到同样的错误。只有当我在服务器上操作它时才会发生这种情况。如果我使用主类在本地测试它,它就可以工作。知道为什么找不到属性文件

回答by WeMakeSoftware

Hibernate just informs you that it wasn't able to find file named hibernate.properties. If you would like to get rid of this log message create webcontent/WEB-INF/hibernate.properties

Hibernate 只是通知您它无法找到名为 hibernate.properties 的文件。如果您想删除此日志消息,请创建 webcontent/WEB-INF/hibernate.properties

You can provide vendor specific properties in the persistence.xml directly like this :

您可以直接在 persistence.xml 中提供特定于供应商的属性,如下所示:

<properties>
 <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>