Java 属性hibernate.connection.Driver\u class 2未指定JDBC驱动程序类
我在学习本教程“Java RESTful Web服务使用MySQL和Hibernate访问数据库” 但我犯了这个错误 警告[http-nio-8084-exec-2]org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure HH000148:属性hibernate.connection.Driver\u class未指定jdbc驱动程序类 警告[http-nio-8084-exec-2]org.hibernate.engine.jdbc.internal.jdbcservicesiml.configure hh000342:无法获得查询元数据的连接:未找到适合jdbc的驱动程序:mysql://localhost:3306/testws 我的文件是HibernateUtil.javaJava 属性hibernate.connection.Driver\u class 2未指定JDBC驱动程序类,java,mysql,hibernate,netbeans,jdbc,Java,Mysql,Hibernate,Netbeans,Jdbc,我在学习本教程“Java RESTful Web服务使用MySQL和Hibernate访问数据库” 但我犯了这个错误 警告[http-nio-8084-exec-2]org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure HH000148:属性hibernate.connection.Driver\u class未指定jdbc驱动程序类 警告[http-nio-8
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
// config file.
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd//hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Opciones de Conexión a Base de Datos -->
<property name="hibernate.conecction.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/testws</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">****</property>
<!-- Dialecto SQL -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Escribe todas las declaraciones SQL ejecutadas a stdout-->
<property name="show_sql">true</property>
<!-- Nombres de clases entidad-->
<mapping class="com.mycompany.testws.model.Person"/>
</session-factory>
</hibernate-configuration>
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/testws
根
****
org.hibernate.dialogue.mysqldialogue
真的
和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.mycompany</groupId>
<artifactId>TestWS</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>TestWS</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>org.jboss.resteasy</id>
<url>http://repository.jboss.org/maven2/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>2.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jettison-provider</artifactId>
<version>2.3.6.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.34</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.2.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
4.0.0
com.mycompany
TestWS
1.0-快照
战争
TestWS
${project.build.directory}/project
UTF-8
org.jboss.resteasy
http://repository.jboss.org/maven2/
爪哇
javaeewebapi
7
假如
org.jboss.resteasy
resteasy jaxrs
2.3.6.2最终版本
org.jboss.resteasy
resteasy jaxb提供程序
2.3.6.2最终版本
org.jboss.resteasy
resteasy抛弃提供者
2.3.6.2最终版本
mysql
mysql连接器java
5.1.34
org.hibernate
冬眠核心
4.2.2.最终版本
org.apache.maven.plugins
maven编译器插件
3.1
1.7
1.7
${annowed.dir}
org.apache.maven.plugins
maven战争插件
2.3
假的
org.apache.maven.plugins
maven依赖插件
2.6
验证
复制
${annowed.dir}
真的
爪哇
javaee认可的api
7
罐子
我将搜索可能的错误,但找不到解决方案,我的驱动程序位于此路径中
C:\TestWS\target\TestWS-1.0-SNAPSHOT\WEB-INF\lib\mysql-connector-java-5.1.34.jar
请帮助我,谢谢配置文件中的连接似乎拼写错误
<property name="hibernate.conecction.driver_class">com.mysql.jdbc.Driver</property>
com.mysql.jdbc.Driver
“连接”应该是连接