org.hibernate.internal.util.config.ConfigurationException: Could not locate cfg.xml resource [/HibernateTest/src/hibernate.cfg.xml]

前端 未结 6 727
故里飘歌
故里飘歌 2020-12-28 11:50

I am trying to connect to Postgresql9.1 in ubuntu with pgadmin3. My Pgadmin3 GUI tool does not give any option to create tables by right clicking the database, but it is ava

6条回答
  •  旧巷少年郎
    2020-12-28 12:08

    You have to use the absolute path of the file otherwise this will not work. Then with that path we build the file and pass it to the configuration.

    private fun getFile(): File {
        val currentWorkingDir = System.getProperty("user.dir")
        val absoulutePath = "$currentWorkingDir/src/main/resources/secret-hibernate.cfg.xml"
        println("Absolute Path of secret-hibernate.cfg.xml: $absoulutePath")
        return File(absoulutePath)
    }
    

    https://stackoverflow.com/a/64084771/5279996

    GL

提交回复
热议问题