hibernate.properties not found

本文记录了Hibernate框架在启动过程中的详细初始化步骤,包括配置文件的加载、连接池的设置、方言的选择等关键技术环节,并展示了实体映射的具体细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 INFO - Hibernate 3.2.5
 INFO - hibernate.properties not found
 INFO - Bytecode provider name : cglib
 INFO - using JDK 1.4 java.sql.Timestamp handling
 INFO - configuring from resource: /hibernate.cfg.xml
 INFO - Configuration resource: /hibernate.cfg.xml
DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
DEBUG - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
DEBUG - dialect=org.hibernate.dialect.SQLServerDialect
DEBUG - connection.url=jdbc:sqlserver://10.188.188.145:1433;databaseName=library
DEBUG - connection.username=sa
DEBUG - connection.password=sa
DEBUG - connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver
DEBUG - myeclipse.connection.profile=Microsoft SQL Server
DEBUG - null<-org.dom4j.tree.DefaultAttribute@16917ee [Attribute: name resource value "com/hibernate/Book.hbm.xml"]
 INFO - Reading mappings from resource : com/hibernate/Book.hbm.xml
DEBUG - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
DEBUG - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
DEBUG - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
 INFO - Mapping class: com.hibernate.Book -> book
DEBUG - Mapped property: id -> ID
DEBUG - Mapped property: serialNumber -> SerialNumber
DEBUG - Mapped property: fullName -> FullName
DEBUG - Mapped property: classId -> ClassID
DEBUG - Mapped property: id -> ID, SerialNumber, FullName, ClassID
 INFO - Configured SessionFactory: null
DEBUG - properties: {hibernate.connection.password=sa, java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin, java.vm.version=11.3-b02, hibernate.connection.username=sa, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=CN, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=F:/MyEclipseWorkspace/BookSystem, java.runtime.version=1.6.0_13-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/endorsed, os.arch=x86, java.io.tmpdir=C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows 2003, sun.jnu.encoding=GBK, java.library.path=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/bin;.;C:/WINDOWS/Sun/Java/bin;C:/WINDOWS/system32;C:/WINDOWS;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin/client;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin;D:/Oracle/product/11.1.0/db_1/bin;D:/PHP/;C:/WINDOWS/system32;D:/Java/jdk1.6.0_10/bin;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Program Files/Microsoft SQL Server/80/Tools/BINN;C:/Program Files/Common Files/Thunder Network/KanKan/Codecs;C:/Program Files/Microsoft SQL Server/100/Tools/Binn/;C:/Program Files/Microsoft SQL Server/100/DTS/Binn/;C:/Program Files/Microsoft SQL Server/100/Tools/Binn/VSShell/Common7/IDE/;D:/Program Files/Microsoft Visual Studio 9.0/Common7/IDE/PrivateAssemblies/;C:/WINDOWS/system32/WindowsPowerShell/v1.0;C:/Program Files/cvsnt;d:/Program Files/StormII/Codec;d:/Program Files/StormII, hibernate.myeclipse.connection.profile=Microsoft SQL Server, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.2, connection.password=sa, user.home=C:/Documents and Settings/Administrator, user.timezone=, connection.username=sa, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=GBK, java.specification.version=1.6, myeclipse.connection.profile=Microsoft SQL Server, hibernate.connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver, user.name=Administrator, java.class.path=F:/MyEclipseWorkspace/BookSystem/WebRoot/WEB-INF/classes;E:/JAVA LIB/struts-2.1.8.1/lib/ognl-2.7.3.jar;E:/JAVA LIB/struts-2.1.8.1/lib/struts2-core-2.1.8.1.jar;E:/JAVA LIB/struts-2.1.8.1/lib/xwork-core-2.1.6.jar;E:/JAVA LIB/struts-2.1.8.1/lib/commons-fileupload-1.2.1.jar;E:/JAVA LIB/struts-2.1.8.1/lib/commons-logging-1.0.4.jar;E:/JAVA LIB/struts-2.1.8.1/lib/freemarker-2.3.15.jar;E:/JAVA LIB/struts-2.1.8.1/lib/commons-io-1.3.2.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/hibernate-annotations.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/hibernate-commons-annotations.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/hibernate-entitymanager.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/hibernate-validator.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/ejb3-persistence.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/jboss-archive-browsing.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/antlr-2.7.6.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/asm.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/asm-attrs.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.1/lib/cglib-2.1.3.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/commons-collections-2.1.1.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/commons-logging-1.0.4.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.1/lib/dom4j-1.6.1.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/ehcache-1.2.3.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/hibernate3.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/jaas.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.1/lib/jaxen-1.1-beta-7.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/javassist.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/jdbc2_0-stdext.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/jta.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.1/lib/log4j-1.2.11.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/xerces-2.6.2.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/xml-apis.jar;F:/MyEclipseWorkspace/BookSystem/WebRoot/WEB-INF/lib/sqljdbc4.jar, hibernate.bytecode.use_reflection_optimizer=false, java.vm.specification.version=1.0, java.home=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre, sun.arch.data.model=32, hibernate.connection.url=jdbc:sqlserver://10.188.188.145:1433;databaseName=library, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, user.language=zh, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.6.0_13, java.ext.dirs=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/ext;C:/WINDOWS/Sun/Java/lib/ext, sun.boot.class.path=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/resources.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/rt.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/sunrsasign.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/jsse.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/jce.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/charsets.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/classes;D:/Program Files/Genuitec/Common/plugins/com.genuitec.eclipse.j2eedt.core_8.0.0.me200911192043/data/libraryset/EE_5/javaee.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.eclipse.j2eedt.core_8.0.0.me200911192043/data/libraryset/EE_5/jsf-impl.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.eclipse.j2eedt.core_8.0.0.me200911192043/data/libraryset/EE_5/jsf-api.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.eclipse.j2eedt.core_8.0.0.me200911192043/data/libraryset/EE_5/jstl-1.2.jar, java.vendor=Sun Microsystems Inc., connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver, file.separator=/, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=windows, connection.url=jdbc:sqlserver://10.188.188.145:1433;databaseName=library, dialect=org.hibernate.dialect.SQLServerDialect, sun.cpu.isalist=}
DEBUG - Preparing to build session factory with filters : {}
DEBUG - processing extends queue
DEBUG - processing collection mappings
DEBUG - processing native query and ResultSetMapping mappings
DEBUG - processing association property references
DEBUG - processing foreign key constraints
 INFO - Using Hibernate built-in connection pool (not for production use!)
 INFO - Hibernate connection pool size: 20
 INFO - autocommit mode: false
 INFO - using driver: com.microsoft.sqlserver.jdbc.SQLServerDriver at URL: jdbc:sqlserver://10.188.188.145:1433;databaseName=library
 INFO - connection properties: {user=sa, password=sa}
DEBUG - total checked-out connections: 0
DEBUG - opening new JDBC connection
DEBUG - created connection to: jdbc:sqlserver://10.188.188.145:1433;databaseName=library, Isolation Level: 2
 INFO - RDBMS: Microsoft SQL Server, version: 8.00.2039
 INFO - JDBC driver: Microsoft SQL Server JDBC Driver 2.0, version: 2.0.1803.100
DEBUG - returning connection to pool, pool size: 1
 INFO - Using dialect: org.hibernate.dialect.SQLServerDialect
 INFO - Using default transaction strategy (direct JDBC transactions)
 INFO - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
 INFO - Automatic flush during beforeCompletion(): disabled
 INFO - Automatic session close at end of transaction: disabled
 INFO - Scrollable result sets: enabled
DEBUG - Wrap result sets: disabled
 INFO - JDBC3 getGeneratedKeys(): enabled
 INFO - Connection release mode: auto
 INFO - Default batch fetch size: 1
 INFO - Generate SQL with comments: disabled
 INFO - Order SQL updates by primary key: disabled
 INFO - Order SQL inserts for batching: disabled
 INFO - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
 INFO - Using ASTQueryTranslatorFactory
 INFO - Query language substitutions: {}
 INFO - JPA-QL strict compliance: disabled
 INFO - Second-level cache: enabled
 INFO - Query cache: disabled
 INFO - Cache provider: org.hibernate.cache.NoCacheProvider
 INFO - Optimize cache for minimal puts: disabled
 INFO - Structured second-level cache entries: disabled
DEBUG - Using dialect defined converter
 INFO - Statistics: disabled
 INFO - Deleted entity synthetic identifier rollback: disabled
 INFO - Default entity-mode: pojo
 INFO - Named query checking : enabled
 INFO - building session factory
DEBUG - Session factory constructed with filter configurations : {}
DEBUG - instantiating session factory with properties: {java.runtime.name=Java(TM) SE Runtime Environment, hibernate.connection.password=sa, sun.boot.library.path=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin, java.vm.version=11.3-b02, hibernate.connection.username=sa, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=CN, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=F:/MyEclipseWorkspace/BookSystem, java.runtime.version=1.6.0_13-b03, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/endorsed, os.arch=x86, java.io.tmpdir=C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows 2003, sun.jnu.encoding=GBK, java.library.path=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/bin;.;C:/WINDOWS/Sun/Java/bin;C:/WINDOWS/system32;C:/WINDOWS;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin/client;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/bin;D:/Oracle/product/11.1.0/db_1/bin;D:/PHP/;C:/WINDOWS/system32;D:/Java/jdk1.6.0_10/bin;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Program Files/Microsoft SQL Server/80/Tools/BINN;C:/Program Files/Common Files/Thunder Network/KanKan/Codecs;C:/Program Files/Microsoft SQL Server/100/Tools/Binn/;C:/Program Files/Microsoft SQL Server/100/DTS/Binn/;C:/Program Files/Microsoft SQL Server/100/Tools/Binn/VSShell/Common7/IDE/;D:/Program Files/Microsoft Visual Studio 9.0/Common7/IDE/PrivateAssemblies/;C:/WINDOWS/system32/WindowsPowerShell/v1.0;C:/Program Files/cvsnt;d:/Program Files/StormII/Codec;d:/Program Files/StormII, hibernate.myeclipse.connection.profile=Microsoft SQL Server, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.2, user.home=C:/Documents and Settings/Administrator, connection.password=sa, user.timezone=, java.awt.printerjob=sun.awt.windows.WPrinterJob, connection.username=sa, java.specification.version=1.6, file.encoding=GBK, hibernate.connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver, myeclipse.connection.profile=Microsoft SQL Server, java.class.path=F:/MyEclipseWorkspace/BookSystem/WebRoot/WEB-INF/classes;E:/JAVA LIB/struts-2.1.8.1/lib/ognl-2.7.3.jar;E:/JAVA LIB/struts-2.1.8.1/lib/struts2-core-2.1.8.1.jar;E:/JAVA LIB/struts-2.1.8.1/lib/xwork-core-2.1.6.jar;E:/JAVA LIB/struts-2.1.8.1/lib/commons-fileupload-1.2.1.jar;E:/JAVA LIB/struts-2.1.8.1/lib/commons-logging-1.0.4.jar;E:/JAVA LIB/struts-2.1.8.1/lib/freemarker-2.3.15.jar;E:/JAVA LIB/struts-2.1.8.1/lib/commons-io-1.3.2.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/hibernate-annotations.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/hibernate-commons-annotations.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/hibernate-entitymanager.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/hibernate-validator.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/ejb3-persistence.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/entitymanager/jboss-archive-browsing.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/antlr-2.7.6.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/asm.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/asm-attrs.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.1/lib/cglib-2.1.3.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/commons-collections-2.1.1.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/commons-logging-1.0.4.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.1/lib/dom4j-1.6.1.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/ehcache-1.2.3.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/hibernate3.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/jaas.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.1/lib/jaxen-1.1-beta-7.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.2/lib/javassist.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/jdbc2_0-stdext.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/jta.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.1/lib/log4j-1.2.11.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/xerces-2.6.2.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.org.hibernate.eclipse_3.2.4.CR1-me200911090405/myeclipse-data/3.0/lib/xml-apis.jar;F:/MyEclipseWorkspace/BookSystem/WebRoot/WEB-INF/lib/sqljdbc4.jar, user.name=Administrator, hibernate.bytecode.use_reflection_optimizer=false, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, hibernate.connection.url=jdbc:sqlserver://10.188.188.145:1433;databaseName=library, java.specification.vendor=Sun Microsystems Inc., user.language=zh, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.6.0_13, java.ext.dirs=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/ext;C:/WINDOWS/Sun/Java/lib/ext, sun.boot.class.path=D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/resources.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/rt.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/sunrsasign.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/jsse.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/jce.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/lib/charsets.jar;D:/Program Files/Genuitec/Common/binary/com.sun.java.jdk.win32.x86_1.6.0.013/jre/classes;D:/Program Files/Genuitec/Common/plugins/com.genuitec.eclipse.j2eedt.core_8.0.0.me200911192043/data/libraryset/EE_5/javaee.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.eclipse.j2eedt.core_8.0.0.me200911192043/data/libraryset/EE_5/jsf-impl.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.eclipse.j2eedt.core_8.0.0.me200911192043/data/libraryset/EE_5/jsf-api.jar;D:/Program Files/Genuitec/Common/plugins/com.genuitec.eclipse.j2eedt.core_8.0.0.me200911192043/data/libraryset/EE_5/jstl-1.2.jar, java.vendor=Sun Microsystems Inc., file.separator=/, connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, connection.url=jdbc:sqlserver://10.188.188.145:1433;databaseName=library, sun.cpu.isalist=, dialect=org.hibernate.dialect.SQLServerDialect}
DEBUG - Static SQL for entity: com.hibernate.Book
DEBUG -  Version select: select ID, SerialNumber, FullName, ClassID from Library.dbo.book where ID =? and SerialNumber =? and FullName =? and ClassID =?
DEBUG -  Snapshot select: select book_.ID, book_.SerialNumber, book_.FullName, book_.ClassID from Library.dbo.book book_ where book_.ID=? and book_.SerialNumber=? and book_.FullName=? and book_.ClassID=?
DEBUG -  Insert 0: insert into Library.dbo.book (ID, SerialNumber, FullName, ClassID) values (?, ?, ?, ?)
DEBUG -  Update 0: null
DEBUG -  Delete 0: delete from Library.dbo.book where ID=? and SerialNumber=? and FullName=? and ClassID=?
DEBUG - Static select for entity com.hibernate.Book: select book0_.ID as ID0_0_, book0_.SerialNumber as SerialNu2_0_0_, book0_.FullName as FullName0_0_, book0_.ClassID as ClassID0_0_ from Library.dbo.book book0_ where book0_.ID=? and book0_.SerialNumber=? and book0_.FullName=? and book0_.ClassID=?
DEBUG - Static select for entity com.hibernate.Book: select book0_.ID as ID0_0_, book0_.SerialNumber as SerialNu2_0_0_, book0_.FullName as FullName0_0_, book0_.ClassID as ClassID0_0_ from Library.dbo.book book0_ where book0_.ID=? and book0_.SerialNumber=? and book0_.FullName=? and book0_.ClassID=?
DEBUG - Static select for entity com.hibernate.Book: select book0_.ID as ID0_0_, book0_.SerialNumber as SerialNu2_0_0_, book0_.FullName as FullName0_0_, book0_.ClassID as ClassID0_0_ from Library.dbo.book book0_ with (updlock, rowlock) where book0_.ID=? and book0_.SerialNumber=? and book0_.FullName=? and book0_.ClassID=?
DEBUG - Static select for entity com.hibernate.Book: select book0_.ID as ID0_0_, book0_.SerialNumber as SerialNu2_0_0_, book0_.FullName as FullName0_0_, book0_.ClassID as ClassID0_0_ from Library.dbo.book book0_ with (updlock, rowlock) where book0_.ID=? and book0_.SerialNumber=? and book0_.FullName=? and book0_.ClassID=?
DEBUG - Static select for entity com.hibernate.Book: select book0_.ID as ID0_0_, book0_.SerialNumber as SerialNu2_0_0_, book0_.FullName as FullName0_0_, book0_.ClassID as ClassID0_0_ from Library.dbo.book book0_ with (updlock, rowlock) where book0_.ID=? and book0_.SerialNumber=? and book0_.FullName=? and book0_.ClassID=?
DEBUG - Static select for action ACTION_MERGE on entity com.hibernate.Book: select book0_.ID as ID0_0_, book0_.SerialNumber as SerialNu2_0_0_, book0_.FullName as FullName0_0_, book0_.ClassID as ClassID0_0_ from Library.dbo.book book0_ where book0_.ID=? and book0_.SerialNumber=? and book0_.FullName=? and book0_.ClassID=?
DEBUG - Static select for action ACTION_REFRESH on entity com.hibernate.Book: select book0_.ID as ID0_0_, book0_.SerialNumber as SerialNu2_0_0_, book0_.FullName as FullName0_0_, book0_.ClassID as ClassID0_0_ from Library.dbo.book book0_ where book0_.ID=? and book0_.SerialNumber=? and book0_.FullName=? and book0_.ClassID=?
DEBUG - initializing class SessionFactoryObjectFactory
DEBUG - registered: 8a3c3c112721a025012721a0271a0000 (unnamed)
 INFO - Not binding factory to JNDI, no JNDI name configured
DEBUG - instantiated session factory
DEBUG - Checking 0 named HQL queries
DEBUG - Checking 0 named SQL queries
DEBUG - opened session at timestamp: 12675794962
DEBUG - unable to locate HQL query plan in cache; generating (from Book)
DEBUG - parse() - HQL: from com.hibernate.Book
DEBUG - --- HQL AST ---
 /-[QUERY] 'query'
    /-[SELECT_FROM] 'SELECT_FROM'
       /-[FROM] 'from'
          /-[RANGE] 'RANGE'
             /-[DOT] '.'
                +-[DOT] '.'
                |  +-[IDENT] 'com'
                |  /-[IDENT] 'hibernate'
                /-[IDENT] 'Book'

DEBUG - throwQueryException() : no errors
DEBUG - select << begin [level=1, statement=select]
DEBUG - FromClause{level=1} :  com.hibernate.Book (no alias) -> book0_
DEBUG - select : finishing up [level=1, statement=select]
DEBUG - processQuery() :  ( SELECT ( FromClause{level=1} Library.dbo.book book0_ ) )
DEBUG - Derived SELECT clause created.
DEBUG - Using FROM fragment [Library.dbo.book book0_]
DEBUG - select >> end [level=1, statement=select]
DEBUG - --- SQL AST ---
 /-[SELECT] QueryNode: 'SELECT'  querySpaces (Library.dbo.book)
    +-[SELECT_CLAUSE] SelectClause: '{derived select clause}'
    |  /-[SELECT_EXPR] SelectExpressionImpl: 'book0_.ID as ID0_, book0_.SerialNumber as SerialNu2_0_, book0_.FullName as FullName0_, book0_.ClassID as ClassID0_' {FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=Library.dbo.book,tableAlias=book0_,origin=null,colums={,className=com.hibernate.Book}}}
    /-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[book0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
       /-[FROM_FRAGMENT] FromElement: 'Library.dbo.book book0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=Library.dbo.book,tableAlias=book0_,origin=null,colums={,className=com.hibernate.Book}}

DEBUG - throwQueryException() : no errors
DEBUG - HQL: from com.hibernate.Book
DEBUG - SQL: select book0_.ID as ID0_, book0_.SerialNumber as SerialNu2_0_, book0_.FullName as FullName0_, book0_.ClassID as ClassID0_ from Library.dbo.book book0_
DEBUG - throwQueryException() : no errors
DEBUG - HQL param location recognition took 0 mills (from Book)
DEBUG - located HQL query plan in cache (from Book)
DEBUG - find: from Book
DEBUG - named parameters: {}
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - opening JDBC connection
DEBUG - total checked-out connections: 0
DEBUG - using pooled JDBC connection, pool size: 0
DEBUG - select book0_.ID as ID0_, book0_.SerialNumber as SerialNu2_0_, book0_.FullName as FullName0_, book0_.ClassID as ClassID0_ from Library.dbo.book book0_
DEBUG - preparing statement
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - processing result set
DEBUG - result set row: 0
DEBUG - returning '1' as column: ID0_
DEBUG - returning 'sd                                                                                                                           ' as column: SerialNu2_0_
DEBUG - returning 'df' as column: FullName0_
DEBUG - returning '2' as column: ClassID0_
DEBUG - result row: EntityKey[com.hibernate.Book#component[id,serialNumber,fullName,classId]{id=1, classId=2, serialNumber=sd                                                                                                                           , fullName=df}]
DEBUG - Initializing object from ResultSet: [com.hibernate.Book#component[id,serialNumber,fullName,classId]{id=1, classId=2, serialNumber=sd                                                                                                                           , fullName=df}]
DEBUG - Hydrating entity: [com.hibernate.Book#component[id,serialNumber,fullName,classId]{id=1, classId=2, serialNumber=sd                                                                                                                           , fullName=df}]
DEBUG - done processing result set (1 rows)
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - closing statement
DEBUG - total objects hydrated: 1
DEBUG - resolving associations for [com.hibernate.Book#component[id,serialNumber,fullName,classId]{id=1, classId=2, serialNumber=sd                                                                                                                           , fullName=df}]
DEBUG - done materializing entity [com.hibernate.Book#component[id,serialNumber,fullName,classId]{id=1, classId=2, serialNumber=sd                                                                                                                           , fullName=df}]
DEBUG - initializing non-lazy collections
DEBUG - after autocommit
DEBUG - aggressively releasing JDBC connection
DEBUG - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG - returning connection to pool, pool size: 1

 

hibernate.properties not found,是说在classpath里没有找到hibernate.properties的配置文件。
然后hibernate会自动去找hibernate.cfg.xml配置文件,hibernate找到了此配置文件,然后就进行初始化操作。

没有说有错误异常,应该是正常的

<think>好的,用户的问题是Spring Boot 2.5.1中ParentServiceImpl类的@Autowired无法注入SessionFactory的Bean。我需要先理清可能的原因和解决方案。 首先,用户提到使用@Autowired注入SessionFactory,但Bean找不到。可能的原因有几个: 1. **缺少Hibernate依赖**:Spring Boot项目如果没有正确引入Hibernate相关依赖,特别是spring-boot-starter-data-jpa,可能导致SessionFactory无法自动配置。需要检查pom.xml或build.gradle中是否有相关依赖。 2. **配置问题**:虽然Spring Boot会自动配置SessionFactory,但如果数据源配置不正确,比如数据库连接信息错误,可能导致Hibernate无法初始化,从而Bean未创建。 3. **包扫描问题**:如果ParentServiceImpl所在的包不在Spring Boot的主应用类扫描范围内,可能导致@Component或@Repository等注解未被识别,进而Bean未注册。 4. **手动配置SessionFactory**:如果用户自定义了SessionFactory的配置,但没有正确创建Bean,或者与自动配置冲突,可能导致注入失败。 接下来,我需要参考用户提供的引用内容。引用[1]中提到了添加spring-boot-starter-web依赖,但这里的问题可能与数据访问层相关,所以需要检查是否添加了spring-boot-starter-data-jpa。引用[3]提到项目使用了Nacos、Spring Cloud等,但用户当前的问题可能更基础,与Hibernate配置有关。 解决方案步骤可能包括: - 确保添加了spring-boot-starter-data-jpa依赖,这会引入Hibernate相关库。 - 检查数据源配置是否正确,确保application.properties中有正确的数据库连接信息。 - 确认主应用类所在的包是否包含ParentServiceImpl,或者使用@ComponentScan手动指定包路径。 - 如果使用自定义配置,可能需要通过@Bean方法显式定义SessionFactory,并确保使用LocalSessionFactoryBean。 此外,需要提醒用户检查异常日志,查看是否有具体的错误信息,比如Bean创建异常或数据源连接失败,这些信息有助于更精准地定位问题。 可能用户在使用过程中忽略了JPA的自动配置条件,比如没有配置数据源,导致Hibernate相关的Bean没有被创建。或者,可能误用了JPA和Hibernate的混合配置,导致冲突。 最后,需要给出具体的代码示例,比如添加依赖、配置数据源、检查包结构,以及如何自定义SessionFactory的Bean定义,帮助用户一步步解决问题。</think>### Spring Boot 2.5.1 中 `@Autowired` 注入 `SessionFactory` 失败问题解决指南 --- #### **1. 问题定位与分析** 在 Spring Boot 2.5.1 中,`@Autowired` 无法注入 `org.hibernate.SessionFactory` 的根本原因通常是 **Hibernate/JPA 配置缺失**或 **Bean 未被正确注册**。以下是具体原因和验证方法: --- #### **2. 核心解决方案** ##### **(1) 添加 Hibernate/JPA 依赖** **问题**:未正确引入 `spring-boot-starter-data-jpa`,导致 Hibernate 核心类和 `SessionFactory` 未自动配置。 **解决**:在 `pom.xml` 中添加以下依赖(与 Spring Boot 2.5.1 兼容): ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <version>2.5.1</version> </dependency> ``` 此依赖会自动引入 Hibernate 5.4.x(Spring Boot 2.5.1 默认版本)和 `SessionFactory` 相关类[^1]。 --- ##### **(2) 检查数据源配置** **问题**:未配置数据库连接信息,导致 `SessionFactory` 初始化失败。 **解决**:在 `application.properties` 中添加数据源配置(以 MySQL 为例): ```properties spring.datasource.url=jdbc:mysql://localhost:3306/your_db?useSSL=false spring.datasource.username=root spring.datasource.password=123456 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # Hibernate 配置 spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect ``` **验证**:启动应用,若控制台输出 `Hibernate: create table...`,则表明 Hibernate 已初始化成功。 --- ##### **(3) 包扫描范围检查** **问题**:`ParentServiceImpl` 类所在的包未被 Spring Boot 主类扫描。 **解决**:确保主类包路径包含服务类(示例结构): ```java @SpringBootApplication // 显式指定扫描包(若服务类不在主类同级或子包下) @ComponentScan(basePackages = {"com.example.service", "com.example.repository"}) public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` --- ##### **(4) 手动注册 SessionFactory Bean(可选)** **场景**:需自定义 `SessionFactory`(如多数据源场景)。 **解决**:通过 `LocalSessionFactoryBean` 显式定义 Bean: ```java @Configuration public class HibernateConfig { @Autowired private DataSource dataSource; @Bean public LocalSessionFactoryBean sessionFactory() { LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(dataSource); sessionFactory.setPackagesToScan("com.example.entity"); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; } private Properties hibernateProperties() { Properties props = new Properties(); props.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect"); props.put("hibernate.show_sql", "true"); return props; } } ``` **注入使用**: ```java @Service public class ParentServiceImpl { @Autowired private SessionFactory sessionFactory; // 直接注入 } ``` --- #### **3. 常见错误排查** | **错误现象** | **解决方案** | |---------------------------------------|----------------------------------------------------------------------------| | `No qualifying bean of type 'org.hibernate.SessionFactory'` | 检查是否漏掉 `spring-boot-starter-data-jpa` 依赖或数据源配置错误。 | | `BeanCreationException: Error creating bean with name 'sessionFactory'` | 检查数据库连接信息是否正确,或手动定义 `SessionFactory` Bean。 | | `Field sessionFactory in ... required a bean of type 'org.hibernate.SessionFactory'` | 确认包扫描范围是否包含 `HibernateConfig` 或服务类。 | --- #### **4. 验证步骤** 1. **依赖树检查**: ```bash mvn dependency:tree | grep hibernate-core ``` 输出应包含 `hibernate-core-5.4.x`(与 Spring Boot 2.5.1 匹配)。 2. **启动日志分析**: 若启动日志中包含 `HHH000412: Hibernate ORM core version 5.4.32.Final`,则表明 Hibernate 已正确加载。 --- #### **5. 扩展建议** - **升级到 Spring Boot 2.7.x**:若需长期维护,建议升级至 LTS 版本(如 2.7.18)以获得更好的兼容性[^1]。 - **使用 Spring Data JPA**:推荐通过 `JpaRepository` 替代直接操作 `SessionFactory`,简化数据库访问。 --- ### 相关问题 1. Spring Boot 2.5.1 如何配置多数据源并注入不同的 `SessionFactory`? 2. 如何在 Spring Boot 中自定义 Hibernate 的命名策略? 3. Spring Data JPA 和原生 Hibernate API 的性能对比如何? [^1]: Spring Boot 2.5.x 官方文档 [^2]: Hibernate SessionFactory 配置指南
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值