Vaadin 7/maven - project setup question

I’ve not used maven to create a project before. Just created a vaadin 7 project. I can compile the default project and run it by dropping it into my tomcat container - so the basic layout is ok.

I want to open a property file. I used to put that in a directory under src/resources/config.properties and open /resources/config.properties. In the current setup, I see the code in src/main/java/com… I put my config file in src/main/resources/config.properties - but my program doesn’t seem to locate the file - what is the correct path I need to use to open that config file?

thanks

nbc

Hi, src/main/resources is the correct place to put your configuration file.
If you put the file in in src/main/resources/config.properties it will be packaged in the root of the jar file, so you can load for example as getClass().getResourceAsStream(“/config.properties”)

HTH
Marco

Thanks - I’ll try that…

nbc

The same applies if the

config.properties

file happens to be a
resource bundle
loaded with:

ResourceBundle.getBundle( "com.company.app.package.config", ... )

where it has to be located in

${project.basedir}/src/main/resources/com/company/app/package/config.properties

.

Or to be precise: according to how


//


is declared last in your top-down POM hierarchy.

I can read my config.properties file now. Thanks very much. A related question…

I used to include a ‘persistence.xml’ file in the META_INF directory which contained info about my databases. I don’t see a persistence.xml file being packaged now. I am trying to read from a couple of databases on different machines, each of which should have a persistence.xml file in its jar file. Can someone tell me how to configure my pom.xml (or something else) to include the correct persistence information for my database access?

I suggest to create another thread for this new question. Otherwise nobody will recognize it since there’s no according topic title in the forum’s topic list.