创建休眠配置:未设置“休眠.dialect”时对DialectResolutionInfo的访问不能为空

时间:2019-05-14 09:12:40

标签: java mysql hibernate maven

根据视频教程,我正在尝试学习使用休眠模式。 我在Eclipse中创建了一个Maven项目,并添加了所需的库。 当我尝试使用hibernate插件向导构建hibernate配置文件时,完成按钮不起作用。

休眠版本为5.4.2,而我的DBMS为Mysql。我正在使用5.1.47 jdbc驱动程序。当我在eclipse中创建到项目外部数据库的连接时,它工作正常,并且ping成功。

这是错误日志:

org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
    at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:175)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:118)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:473)
    at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:84)
    at org.hibernate.boot.MetadataSources.buildMetadata(MetadataSources.java:184)
    at org.jboss.tools.hibernate.runtime.v_5_4.internal.util.MetadataHelper.buildFromMetadataSources(MetadataHelper.java:49)
    at org.jboss.tools.hibernate.runtime.v_5_4.internal.util.MetadataHelper.getMetadata(MetadataHelper.java:21)
    at org.jboss.tools.hibernate.runtime.v_5_4.internal.ConfigurationFacadeImpl.getMetadata(ConfigurationFacadeImpl.java:174)
    at org.jboss.tools.hibernate.runtime.v_5_4.internal.util.ConfigurationMetadataDescriptor.createMetadata(ConfigurationMetadataDescriptor.java:20)
    at org.hibernate.tool.hbm2x.AbstractExporter.buildMetadata(AbstractExporter.java:206)
    at org.hibernate.tool.hbm2x.AbstractExporter.getMetadata(AbstractExporter.java:56)
    at org.hibernate.tool.hbm2x.AbstractExporter.setupContext(AbstractExporter.java:177)
    at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:104)
    at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jboss.tools.hibernate.runtime.common.Util.invokeMethod(Util.java:43)
    at org.jboss.tools.hibernate.runtime.common.AbstractExporterFacade.start(AbstractExporterFacade.java:72)
    at org.hibernate.eclipse.console.wizards.NewConfigurationWizard.openContentStream(NewConfigurationWizard.java:301)
    at org.hibernate.eclipse.console.wizards.NewConfigurationWizard.access$2(NewConfigurationWizard.java:295)
    at org.hibernate.eclipse.console.wizards.NewConfigurationWizard$1.getInitialContents(NewConfigurationWizard.java:163)
    at org.eclipse.ui.dialogs.WizardNewFileCreationPage.createNewFile(WizardNewFileCreationPage.java:383)
    at org.hibernate.eclipse.console.wizards.NewConfigurationWizard.performFinish(NewConfigurationWizard.java:198)
    at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:775)
    at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:414)
    at org.eclipse.jface.dialogs.Dialog.lambda$0(Dialog.java:622)
    at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:84)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4131)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1055)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3944)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3547)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:823)
    at org.eclipse.jface.window.Window.open(Window.java:799)
    at org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:136)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:474)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:568)
    at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:400)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4131)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1055)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3944)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3547)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:823)
    at org.eclipse.jface.window.Window.open(Window.java:799)
    at org.eclipse.ui.internal.views.log.EventDetailsDialog.open(EventDetailsDialog.java:191)
    at org.eclipse.ui.internal.views.log.EventDetailsDialogAction.run(EventDetailsDialogAction.java:102)
    at org.eclipse.ui.internal.views.log.LogView.lambda$2(LogView.java:565)
    at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:833)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.ui.internal.JFaceUtil.lambda$0(JFaceUtil.java:47)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:176)
    at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:830)
    at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1518)
    at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1260)
    at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:253)
    at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:251)
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:310)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4131)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1055)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3944)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3547)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:566)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:155)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
    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 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:661)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1476)
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:100)
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
    ... 92 more

这是我的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.trainig</groupId>
  <artifactId>hibernate</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>hibernate</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.4.2.Final</version>
</dependency>
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.47</version>
</dependency>

  </dependencies>


</project>

0 个答案:

没有答案