Reputation: 4931
Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
My configuration file in src/. still i got this error. can some one spot my mistake.
Upvotes: 0
Views: 360
Reputation: 16110
You're using maven with the standard directory layout, so it'll compile the stuff it finds under src/main/java
, and copy the stuff it finds under src/main/resources
. Your config file is not in any type of source
, resource
, or test
path. It's close, but it's not in any of them, and it needs to be for maven to do something with it.
In order for you to load it, it needs to be copied to your target directory, so it must be in one of the directories maven works with. In this case it needs to be in src/main/resources
so that it's copied to the target/classes directory.
Now, I have no idea what that configuration object is, or where it came from, but the config file when it's in the right place will be a resource on the classpath, not a file on the filesystem, so you may have to change the way you're loading it. I'd try what you have first, and it that doesn't work try 'classpath:hibernate.cfg.xml'
and see how you go. We'd need a lot more information to fix this for you if it doesn't work.
Upvotes: 2