小段大帅 2017-03-29 14:39 采纳率: 0%
浏览 842

hibernate问题,搞了n久还是不行,求大神指点

这是错误提示

三月 29, 2017 10:33:16 下午 org.hibernate.annotations.common.Version
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
三月 29, 2017 10:33:16 下午 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.2.Final}
三月 29, 2017 10:33:16 下午 org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
三月 29, 2017 10:33:16 下午 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
三月 29, 2017 10:33:16 下午 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
三月 29, 2017 10:33:16 下午 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /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-mapping-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.password">1995</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate?characterEncoding=utf8&&amp;serverTimezone=UTC</property>
<!--         <property name="jdbcUrl"> jdbc:mysql://localhost:3306/hibernate?characterEncoding=utf8&amp;serverTimezone=UTC</property> -->
        <property name="hibernate.current_session_context_class">thread</property>
        <!--        是否在控制台打印sql -->
        <property name="show_sql">true</property>
        <!--        是否对sql进行格式化 -->
        <property name="format_sql">true</property>
        <!--        指定自动生成数据表的策略 -->
        <property name="hbm2ddl">update</property>
        <!--        指定关联的hbm.xml -->
        <mapping resource="entity/Users.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

  • 写回答

4条回答 默认 最新

  • 小段大帅 2017-03-29 14:36
    关注

    这是测试类

    public class TestUsers {
    @Test
    public void testSchemaExport(){
    Configuration configuration = new Configuration().configure();
    ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
    .applySettings(configuration.getProperties()).buildServiceRegistry();
    SessionFactory sf = configuration.buildSessionFactory(serviceRegistry);
    Session session = sf.openSession();
    // Transaction trans = session.beginTransaction();
    //

    // Users user = new Users("1","2","3");
    // session.save(user);
    //

    // trans.commit();
    SchemaExport export = new SchemaExport(configuration);
    export.create(true,true);
    session.close();
    sf.close();
    }
    }

    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题