3

在我启动 Hibernate 5 应用程序的那一刻,我疯狂地收到这些警告。我将如何摆脱它们?这是我的配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!--
Program developed by Hassan Althaf.
Copyright © 2015, Hassan Althaf.
Website: http://hassanalthaf.com
-->

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">
            org.hibernate.dialect.MySQLDialect
        </property>
        <property name="hibernate.connecton.driver_class">
            com.mysql.jdbc.Driver
        </property>
        <property name="hibernate.connection.url">
            jdbc:mysql://127.0.0.1:3306/telemart
        </property>
        <property name="hibernate.connection.username">
            root
        </property>
        <property name="hibernate.connection.password">
            php123
        </property>
        <mapping resource="com/hassanalthaf/telemart/users/User.hbm.xml"/>
        <mapping resource="com/hassanalthaf/telemart/customers/Customer.hbm.xml"/>
        <mapping resource="com/hassanalthaf/telemart/inventory/Product.hbm.xml"/>
        <mapping resource="com/hassanalthaf/telemart/orders/Order.hbm.xml"/>
        <mapping resource="com/hassanalthaf/telemart/orders/OrderItem.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

这是整个输出:

ant -f /Users/hassan/NetBeansProjects/TeleMart/TeleMart jfxsa-run
init:
Deleting: /Users/hassan/NetBeansProjects/TeleMart/TeleMart/build/built-jar.properties
deps-jar:
Updating property file: /Users/hassan/NetBeansProjects/TeleMart/TeleMart/build/built-jar.properties
Duplicated project name in import. Project jfx-impl defined first in /Users/hassan/NetBeansProjects/TeleMart/TeleMart/nbproject/jfx-impl.xml and again in /Users/hassan/NetBeansProjects/TeleMart/TeleMart-Preloader/nbproject/jfx-impl.xml
TeleMart-Preloader.init:
TeleMart-Preloader.deps-jar:
Updating property file: /Users/hassan/NetBeansProjects/TeleMart/TeleMart/build/built-jar.properties
TeleMart-Preloader.compile:
Copying 1 file to /Users/hassan/NetBeansProjects/TeleMart/TeleMart-Preloader/build
Copy libraries to /Users/hassan/NetBeansProjects/TeleMart/TeleMart-Preloader/dist/lib.
To run this application from the command line without Ant, try:
/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/java -jar "/Users/hassan/NetBeansProjects/TeleMart/TeleMart-Preloader/dist/TeleMart-Preloader.jar"
Deleting directory /Users/hassan/NetBeansProjects/TeleMart/TeleMart-Preloader/dist/lib
Detected JavaFX Ant API version 1.3
TeleMart-Preloader.jfx-deployment:
TeleMart-Preloader.jar:
compile:
Deleting directory /Users/hassan/NetBeansProjects/TeleMart/TeleMart/dist/lib
Copying 13 files to /Users/hassan/NetBeansProjects/TeleMart/TeleMart/dist/lib
Detected JavaFX Ant API version 1.3
jfx-deployment:
jar:
Copying 25 files to /Users/hassan/NetBeansProjects/TeleMart/TeleMart/dist/run2142585581
jfx-project-run:
Executing /Users/hassan/NetBeansProjects/TeleMart/TeleMart/dist/run2142585581/TeleMart.jar using platform /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin/java
Jan 10, 2016 4:36:32 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.0.6.Final}
Jan 10, 2016 4:36:32 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Jan 10, 2016 4:36:32 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Jan 10, 2016 4:36:32 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-configuration. Use namespace http://www.hibernate.org/dtd/hibernate-configuration instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
Jan 10, 2016 4:36:33 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
Jan 10, 2016 4:36:33 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-mapping. Use namespace http://www.hibernate.org/dtd/hibernate-mapping instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
Jan 10, 2016 4:36:34 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-mapping. Use namespace http://www.hibernate.org/dtd/hibernate-mapping instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
Jan 10, 2016 4:36:34 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-mapping. Use namespace http://www.hibernate.org/dtd/hibernate-mapping instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
Jan 10, 2016 4:36:34 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-mapping. Use namespace http://www.hibernate.org/dtd/hibernate-mapping instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
Jan 10, 2016 4:36:34 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-mapping. Use namespace http://www.hibernate.org/dtd/hibernate-mapping instead.  Support for obsolete DTD/XSD namespaces may be removed at any time.
Jan 10, 2016 4:36:34 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
Jan 10, 2016 4:36:34 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [null] at URL [jdbc:mysql://127.0.0.1:3306/telemart]
Jan 10, 2016 4:36:34 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=root, password=****}
Jan 10, 2016 4:36:34 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
Jan 10, 2016 4:36:34 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
Jan 10, 2016 4:36:34 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
4

1 回答 1

8

问题是您为 Hibernate 配置声明了一个已弃用的命名空间。它指向

http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd

什么时候应该指向

http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd

因此,您需要更改 Hibernate 配置文件的开头(以及在所有其他地方写入此 URL),如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

至于最后一个关于连接池的警告,可以参考这个问题。您需要将自定义连接池添加到您的类路径。一个可能是C3P0,但还有很多其他可用的。

于 2016-01-10T11:11:34.640 回答