- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当有 Internet 连接时,Hibernate 工作正常。但是当没有互联网连接时,它给了我
Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
错误。我认为我的应用程序在运行时试图访问互联网连接。我得到的详细错误如下:-
Dec 22, 2015 6:17:43 PM org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator initiateService WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections Initial SessionFactory creation failed.org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104) at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:209) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843) at com.pos.admin.admin_module.admin_module.hibernatefiles.hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:32) at com.pos.admin.admin_module.admin_module.hibernatefiles.hibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:44) at com.pos.admin.admin_module.main.AdminModule.start(AdminModule.java:21) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(Unknown Source) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(Unknown Source) at com.sun.javafx.application.PlatformImpl.lambda$null$174(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(Unknown Source) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$149(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source) at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source) Caused by: java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ExceptionInInitializerError at com.pos.admin.admin_module.admin_module.hibernatefiles.hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:39) at com.pos.admin.admin_module.admin_module.hibernatefiles.hibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:44) at com.pos.admin.admin_module.main.AdminModule.start(AdminModule.java:21) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(Unknown Source) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(Unknown Source) at com.sun.javafx.application.PlatformImpl.lambda$null$174(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(Unknown Source) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$149(Unknown Source) ... 1 more Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104) at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:209) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843) at com.pos.admin.admin_module.admin_module.hibernatefiles.hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:32) ... 11 more Exception running application com.pos.admin.admin_module.main.AdminModule
我的 pom.xml 文件
<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.pos.admin.admin_module</groupId>
<artifactId>admin_module</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>admin_module</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- <build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build> -->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.5.Final</version>
</dependency> -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.5.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
<!-- <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId>
<version>4.3.5.Final</version> </dependency> -->
<!-- <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId>
<version>5.2.2.Final</version> </dependency> -->
<!-- <dependency> <groupId>javax.el</groupId> <artifactId>javax.el-api</artifactId>
<version>2.2.4</version> </dependency> <dependency> <groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId> <version>2.2.4</version> </dependency> -->
</dependencies>
</project>
我的 hibernate 配置(hibernate.cfg.xml)文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/point_of_sales</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">
</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<!--
<property name="hbm2ddl.auto">update</property> -->
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.Category"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.ProductHeader"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.PurchaseDetail"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.PurchaseHeader"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.SalesDetail"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.SalesHeader"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.Settings"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.Unit"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.User"/>
<mapping class="com.pos.admin.admin_module.hibernatefiles.dto.Supplier"/>
<!-- <mapping class="com.pos.storekeeper.storekeeper_module.hibernateFiles.dto.Supplier"/>
<mapping class="com.pos.storekeeper.storekeeper_module.hibernateFiles.dto.PurchaseHeader"/>
<mapping class="com.pos.storekeeper.storekeeper_module.hibernateFiles.dto.ProductHeader"/>
<mapping class="com.pos.storekeeper.storekeeper_module.hibernateFiles.dto.Category"/>
<mapping class="com.pos.storekeeper.storekeeper_module.hibernateFiles.dto.Unit"/> -->
<!-- <mapping class="com.pos.storekeeper.storekeeper_module.hibernateFiles.dto.User"/> -->
<!-- <mapping class="com.pos.admin.admin_module.admin_module.main.Cart1"/> -->
</session-factory>
</hibernate-configuration>
我在其中创建 Configuration
和 Session
对象的 HibernateUtil 类
public class HibernateUtil {
private static SessionFactory sessionFactory;
private static SessionFactory buildSessionFactory() {
try {
// Create the SessionFactory from hibernate-annotation.cfg.xml
Configuration configuration = new Configuration();
try{
configuration.configure("hibernate.cfg.xml");
}catch(Exception e){
System.out.println("Exception while handling configureation file :" + e.getMessage());
System.out.println("asfsdaf " + configuration);
}
System.out.println("Hibernate Annotation Configuration loaded");
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
System.out.println("Hibernate Annotation serviceRegistry created");
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
if(sessionFactory == null) sessionFactory = buildSessionFactory();
return sessionFactory;
}
public static void closeSessionFactory(){
if(!sessionFactory.isClosed()){
System.out.println("Closing SessionFactory");
sessionFactory.close();
}
}
}
我想解决此问题,因为互联网连接并非始终可用。谢谢
最佳答案
要离线使用 hibernate,你必须在你的 xml 映射和配置文件中更改你的 dtd。确保 hibernate jar 在你的类路径中
for xml mapping file
<!DOCTYPE hibernate-mapping SYSTEM
"classpath://org/hibernate/hibernate-mapping-3.0.dtd">
配置文件:
<!DOCTYPE hibernate-configuration SYSTEM
"classpath://org/hibernate/hibernate-configuration-3.0.dtd">
http://www.journaldev.com/2959/how-to-configure-hibernate-cfg-xml-to-work-offline
关于java - 当没有互联网连接时,Hibernate 给出错误错误 "Access to DialectResolutionInfo cannot be null when ' hibernate.dialect' not set",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34416166/
我确实将 Hibernate 4 替换为 Hibernate 5,现在面临连接元数据的问题。代码片段是: public long getNext(final String sequenceName)
作为开发人员我想开发一个 Spring JPA 来访问 Oracle 9i 数据库以通过存储过程获取记录我想通过 application.yml 连接到数据库,但我使用配置文件 application
我正在与几个人一起开展一个学校项目。当我运行我的项目时,我收到一堆错误,这些错误似乎是由这个引起的:当未设置“hibernate.dialect”时,对 DialectResolutionInfo 的
我知道这是一个常见问题,但没有一个可用的解决方案适合我。下面是我的 booltstraps.xml: Simple bean to handle initializati
Spring 4.3.4 hibernate 5.1.15作为从 3 到 5.1.15 的 hibernate 的一部分,我遇到了这个错误。 正常的应用程序启动可以工作,但如果我使用相同的设置运行 D
我正在使用 java-play-spring 模板(可在此处获取: https://github.com/jamesward/play-java-spring#master ),目前我正在尝试从默认的
使用 maven 创建 Hibernate 测试项目。 当我运行项目时,它生成异常: org.hibernate.engine.jdbc.connections.internal.Connection
我正在尝试运行一个通过 spring-jpa 使用 hibernate 的 spring-boot 应用程序,但出现此错误: Caused by: org.hibernate.HibernateExc
我有一个使用 Spring Repository 框架和 MySQL 数据库的应用程序。我目前已将其部署在 Tomcat 7 上。 一旦我部署并尝试登录到应用程序(第一次调用数据库),我收到以下异常:
我正在使用 Hibernate 最新版本 4.3.5.Final。 我的hibernate.cfg.xml文件内容: com.mysql.jdbc.Driver jdbc:my
我有一个 Spring Boot JPA 应用程序。每当我尝试运行它时,它都会失败: Caused by: org.hibernate.HibernateException: Access to Di
当有 Internet 连接时,Hibernate 工作正常。但是当没有互联网连接时,它给了我 Access to DialectResolutionInfo cannot be null when
我有一个 spring & hibernate 应用程序。当我使用 spring-boot:run 启动我的应用程序时,它可以正常工作。但是当我构建一个 war 文件并想将它部署到我的 tomcat7
即使设置 hibernate.dialect 属性后,我也会遇到异常。我使用的是 hibernate 5.0.11 和 spring boot 1.4.2,mysql 版本为 5.7 applicat
我正在尝试在我的 spring-boot 项目中配置 hibernate 。 我有 application.properties 文件 spring.datasource.url=jdbc:mysql
当我在远程连接到 Google Cloud SQL (MySQL) 的本地主机中运行程序时,它可以正常工作。一旦程序部署在 Google App Engine 中,所有必要的 IAM 权限都已到位,这
我是一名优秀的程序员,十分优秀!