D:\Last\hibernate.cfg.xml 你这是在哪里改的绝对路径?

解决方案 »

  1.   

    你打包错误,用winar打开jar,然后看看根目录有文件伐,没有的话丢1个
      

  2.   

    用winar打开jar,有这个hibernate.cfg.xml文件
      

  3.   

    你用的那个config方法 不带参数的吗
      

  4.   

    “D:\Last\hibernate.cfg.xml “是在sessionFactory = new Configuration().configure("D:\\Last\\hibernate.cfg.xml").buildSessionFactory();         Configuration cfg=new Configuration();
              sessionFactory = cfg.configure()里面加上的
      

  5.   

    不知道你的业务逻辑
    不过你改下看看
    在sessionFactory = new Configuration().configure(new File("D:\\Last\\hibernate.cfg.xml")).buildSessionFactory();
      

  6.   

    org.hibernate.hql.ast.QuerySyntaxError: EqkCata(实体类) is not mapped. [from EqkCata as
    a where a.Id=0]
            at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.j
    ava:63)
            at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl
    .java:196)
            at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorIm
    pl.java:130)
            at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl
    .java:83)
            at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.jav
    a:427)
            at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
            at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
            at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
            at Manage.cezhen.control.CeZhenFaBuMuLuControl.getBy(CeZhenFaBuMuLuContr
    ol.java:91)
            at Manage.cezhen.control.CeZhenFaBuControl.add(CeZhenFaBuControl.java:59
    )
            at Manage.cezhen.control.WriteDataToDataBase.writeData(WriteDataToDataBa
    se.java:58)
            at Manage.CeZhenMain.main(CeZhenMain.java:15)
    这是错误
      

  7.   

    <mapping resource="你这里怎么写的"/>
      

  8.   

    <mapping resource="D:\\Last\\EqkCata.hbm.xml"/>
            <mapping resource="D:\\Last\\EqkPhaseDat2.hbm.xml"/>
      

  9.   

    <mapping resource="EqkCata.hbm.xml"/>
      

  10.   

    <mapping resource="EqkCata.hbm.xml"/>这样写就是因为找不到,我才改为绝对路径的,真奇怪了,就是不行啊
      

  11.   

    前面自己试验了下
    Configuration c=new Configuration().configure(new File("d:\\hibernate.cfg.xml"));
    c.addDirectory(new File("D:\\D"));
    sessionFactory =c.buildSessionFactory();
    我是把mapping放在D:\\D下。
    这样就可以了但是记住目录要干净,他会搜索目录下所有的子目录的其它mapping
      

  12.   

    <mapping resource="EqkCata.hbm.xml"/>需要加上这个类的包名的