我已经在maven项目的resources文件夹中按如下所示设置了休眠配置文件。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="dialect">org.hibernate.dialect.SQLiteDialect</property>
<property name="connection.driver_class">org.sqlite.JDBC</property>
<property name="connection.url">jdbc:sqlite:db.sqlite</property>
<property name="connection.username"></property>
<property name="connection.password"></property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="model.User" />
</session-factory>
</hibernate-configuration>
pom.xml文件的内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sagar</groupId>
<artifactId>RestrauntManagementSystem</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.25.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.zsoltfabok/sqlite-dialect -->
<dependency>
<groupId>com.zsoltfabok</groupId>
<artifactId>sqlite-dialect</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
但是我无法连接到数据库并将记录添加到表中。 我遇到以下错误:
/ usr / lib / jvm / java-8-oracle / bin / java -javaagent:/home/kazekage/Programs/idea-IU-183.5429.30/lib/idea_rt.jar=40971:/home/kazekage/Programs/idea-IU-183.5429.30/bin -Dfile.encoding = UTF-8 -classpath /usr/lib/jvm/java-8-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-8-oracle/jre/lib/deploy。 jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/dnsns.jar:/ usr /lib/jvm/java-8-oracle/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/jfxrt.jar:/usr/lib/jvm /java-8-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-8 -oracle / jre / lib / ext / sunec.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/sunjce_provider.jar:/ usr / lib / jvm / java-8-oracle / jre /lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-8-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-8-oracle/jre/lib/javaws .jar:/usr/lib/jvm/java-8-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jfr.jar:/ usr / lib / jvm / java-8-oracle / jre / lib / jfxswt.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jsse.jar:/ usr / lib / jvm / java-8-oracle / jre / lib / management-agent.jar:/usr/lib/jvm/java-8-oracle/jre/lib/plugin.jar:/ usr / lib / jvm / java-8-oracle / jre / li b / resources.jar:/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar:/ home / kazekage / IdeaProjects / RestrauntManagementSystem / target / classes:/ home / kazekage / IdeaProjects / RestrauntManagementSystem / lib /classmate-1.3.4.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/antlr-2.7.7.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/dom4j-2.1.1.jar:/home/ kazekage / IdeaProjects / RestrauntManagementSystem / lib / hibernate-commons-annotations-5.1.0.Final.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/istack-commons-runtime-3.0.7.jar:/ home / kazekage / IdeaProjects / RestrauntManagementSystem / lib / byte-buddy-1.9.5.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/FastInfoset-1.2.15.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/javassist-3.24。 0-GA.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/jandex-2.0.5.Final.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/javax.activation-api-1.2.0.jar: / home / kazekage / IdeaProjects / RestrauntMan agementSystem / lib / jaxb-api-2.3.1.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/javax.persistence-api-2.2.jar:/ home / kazekage / IdeaProjects / RestrauntManagementSystem / lib / jboss-logging- 3.3.2.Final.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/stax-ex-1.8.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/hibernate-core-5.4.1.Final.jar: /home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/jboss-transaction-api_1.2_spec-1.1.1.Final.jar:/home/kazekage/IdeaProjects/RestrauntManagementSystem/lib/jaxb-runtime-2.3.1.jar:/home /kazekage/IdeaProjects/RestrauntManagementSystem/lib/txw2-2.3.1.jar:/home/kazekage/.m2/repository/org/hibernate/hibernate-core/5.4.1.Final/hibernate-core-5.4.1.Final .jar:/home/kazekage/.m2/repository/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/home/kazekage/.m2/repository /javax/persistence/javax.persistence-api/2.2/javax.persistence-api-2.2.jar:/home/kazekage/.m2/repository/org/javassist/javassist/3 .24.0-GA / javassist-3.24.0-GA.jar:/home/kazekage/.m2/repository/net/bytebuddy/byte-buddy/1.9.5/byte-buddy-1.9.5.jar:/ home / kazekage / .m2 / repository / antlr / antlr / 2.7.7 / antlr-2.7.7.jar:/home/kazekage/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec /1.1.1.Final/jboss-transaction-api_1.2_spec-1.1.1.Final.jar:/home/kazekage/.m2/repository/org/jboss/jandex/2.0.5.Final/jandex-2.0.5 .final.jar:/home/kazekage/.m2/repository/com/fasterxml/classmate/1.3.4/classmate-1.3.4.jar:/home/kazekage/.m2/repository/javax/activation/javax.activation -api / 1.2.0 / javax.activation-api-1.2.0.jar:/home/kazekage/.m2/repository/org/dom4j/dom4j/2.1.1/dom4j-2.1.1.jar:/ home / kazekage / .m2 / repository / org / hibernate / common / hibernate-commons-annotations / 5.1.0.Final / hibernate-commons-annotations-5.1.0.Final.jar:/home/kazekage/.m2/repository/javax /xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/home/kazekage/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1/jaxb-runtime -2.3.1.jar:/home/kazekage/.m2/repos itory / org / glassfish / jaxb / txw2 / 2.3.1 / txw2-2.3.1.jar:/home/kazekage/.m2/repository/com/sun/istack/istack-istack-commons-runtime/3.0.7/istack- commons-runtime-3.0.7.jar:/home/kazekage/.m2/repository/org/jvnet/staxex/stax-ex/1.8/stax-ex-1.8.jar:/home/kazekage/.m2/repository/ com / sun / xml / fastinfoset / FastInfoset / 1.2.15 / FastInfoset-1.2.15.jar:/home/kazekage/.m2/repository/org/xerial/sqlite-jdbc/3.25.2/sqlite-jdbc-3.25。 2.jar:/home/kazekage/.m2/repository/com/zsoltfabok/sqlite-dialect/1.0/sqlite-dialect-1.0.jar sample.Main Gtk-消息:21:37:09.773:无法加载模块 “ canberra-gtk-module” 2019年2月24日9:37:10 PM org.hibernate.Version logVersion INFO:HHH000412:Hibernate Core {5.4.1.Final} 2019年2月24日 下午9:37:10 org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity WARN:HHH90000012:公认的过时休眠 名称空间http://hibernate.sourceforge.net/hibernate-configuration。 使用名称空间http://www.hibernate.org/dtd/hibernate-configuration 代替。可以在以下位置删除对过时的DTD / XSD名称空间的支持: 任何时候。应用程序启动方法异常 java.lang.reflect.InvocationTargetException在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)位于 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498)在 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) 在 com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498)在 sun.launcher.LauncherHelper $ FXHelper.main(LauncherHelper.java:767) 由以下原因引起:java.lang.RuntimeException:应用程序启动中的异常 方法 com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) 在 com.sun.javafx.application.LauncherImpl.lambda $ launchApplication $ 412(LauncherImpl.java:182) 在java.lang.Thread.run(Thread.java:748)造成原因: org.hibernate.internal.util.config.ConfigurationException:无法执行 在资源的第17行和第27列执行解组 hibernate.cfg.xml。消息:cvc-complex-type.2.3:元素 'session-factory'不能有字符[children],因为类型是 内容类型是仅元素。在 org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:133) 在 org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65) 在 org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57) 在 org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:165) 在org.hibernate.cfg.Configuration.configure(Configuration.java:258) 在org.hibernate.cfg.Configuration.configure(Configuration.java:244) 在sample.Main.start(Main.java:18)在 com.sun.javafx.application.LauncherImpl.lambda $ launchApplication1 $ 419(LauncherImpl.java:863) 在 com.sun.javafx.application.PlatformImpl.lambda $ runAndWait $ 399(PlatformImpl.java:326) 在 com.sun.javafx.application.PlatformImpl.lambda $ null $ 397(PlatformImpl.java:295) 在java.security.AccessController.doPrivileged(本机方法)在 com.sun.javafx.application.PlatformImpl.lambda $ runLater $ 398(PlatformImpl.java:294) 在 com.sun.glass.ui.InvokeLaterDispatcher $ Future.run(InvokeLaterDispatcher.java:95) 在com.sun.glass.ui.gtk.GtkApplication._runLoop(本机方法)处 com.sun.glass.ui.gtk.GtkApplication.lambda $ null $ 203(GtkApplication.java:139) ... 1更多原因:javax.xml.bind.UnmarshalException -带有链接的异常:[org.xml.sax.SAXParseException; lineNumber:17; columnNumber:27; cvc-complex-type.2.3:元素“会话工厂” 不能有字符[children],因为类型的内容类型是 仅元素。] com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:483) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:463) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:435) 在 org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:126) ... 15更多原因:org.xml.sax.SAXParseException; lineNumber:17; columnNumber:27; cvc-complex-type.2.3:元素“会话工厂” 不能有字符[children],因为类型的内容类型是 仅元素。在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) 在 com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) 在 com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator $ XSIErrorReporter.reportError(XMLSchemaValidator.java:453) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3231) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidComplexType(XMLSchemaValidator.java:3194) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3154) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3056) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2135) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:854) 在 com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.endElement(ValidatorHandlerImpl.java:582) 在 com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.endElement(ValidatingUnmarshaller.java:106) 在 com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.endElement(InterningXmlVisitor.java:81) 在 com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.handleEndElement(StAXEventConnector.java:234) 在 com.sun.xml.bind.v2.runtime.unmarshaller.StAXEventConnector.bridge(StAXEventConnector.java:135) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:460) ... 17个以上正在运行应用程序示例的异常。主要
以退出代码1完成的过程