java-hibernate.cfg.xml-无法解析文件中的驱动程序

ubby3x7f  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(331)

我正在使用hibernate将我的项目连接到mysql,但hibernate.cfg.xml文件出错-无法解析包mysql(以及包cj、jdbc等)。
这是密码-

<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="connection.url">jdbc:mysql://localhost:3306/theprocess?useUnicode=true&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC</property>
    <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
    <property name="connection.username">root</property>
    <property name="connection.password">Amit4089</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <!-- DB schema will be updated if needed -->
    <property name="hbm2ddl.auto">update</property>
    <mapping class="com.example.WebAppProcess20.Entities.ClientsEntity"/>
    <mapping class="com.example.WebAppProcess20.Entities.InvoicesEntity"/>
    <mapping class="com.example.WebAppProcess20.Entities.OrdersEntity"/>
    <mapping class="com.example.WebAppProcess20.Entities.OrdersitemsEntity"/>
    <mapping class="com.example.WebAppProcess20.Entities.ProductsEntity"/>
  </session-factory>
</hibernate-configuration>

代码的第五行就是我要说的。
问题是,依赖关系被正确地声明,并且同一个文件在我的项目伙伴处工作。
(Spring框架)。

更新1-添加依赖项

<dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.11</version>
    </dependency>

烟囱

19:28:27.282 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Unable to load or instantiate JPA aware resolver org.hibernate.validator.internal.engine.resolver.JPATraversableResolver. All properties will per default be traversable.
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator as ValidatorFactory-scoped message interpolator.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.TraverseAllTraversableResolver as ValidatorFactory-scoped traversable resolver.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.

`有什么想法吗?

yqlxgs2m

yqlxgs2m1#

这个错误从你的帖子上看不清楚。但要确保 MySQLDialect 与您正在使用的mysql版本兼容。
还有其他的 MySQLDialect 适用于5.x之前的版本。然后就是了 MySQL55Dialect 以及 MySQL57Dialect 以及5.5版和5.7版。

相关问题