You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Marco Mistroni <mm...@gmail.com> on 2005/08/09 11:32:02 UTC
Maven properties inside java code
Hello all,
i am using Maven to build my project, but i am stuck with a problem.
In running my tests, i would like to reuse inside my tests some
properties defined in my project.properties.
for example, i have to load a connection to a database (in my dbunit
test), and i would like to pick databasename,user,password etc from
project.properties.
i have defined thos eproperties in project.properties, and in my
dbunit file i am calling
System.getProperty("db.user") for example
but i get back null
can anyone help me ou t?>
thanx in advance and regards
marco
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Maven properties inside java code
Posted by Thomas Van de Velde <th...@gmail.com>.
Marco,
You have to pass the location of poroject.properties to the JVM by adding -
Dproperties.path=/yourpath/to/project.properties. Then you use the Java
properties api to load this properties file and read your key.
Rgds,
Thomas
On 8/9/05, Marco Mistroni <mm...@gmail.com> wrote:
>
> Hello all,
> i am using Maven to build my project, but i am stuck with a problem.
> In running my tests, i would like to reuse inside my tests some
> properties defined in my project.properties.
> for example, i have to load a connection to a database (in my dbunit
> test), and i would like to pick databasename,user,password etc from
> project.properties.
>
> i have defined thos eproperties in project.properties, and in my
> dbunit file i am calling
> System.getProperty("db.user") for example
>
> but i get back null
>
> can anyone help me ou t?>
>
> thanx in advance and regards
> marco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Maven properties inside java code / solved
Posted by Marco Mistroni <mm...@gmail.com>.
hello,
sorry i solve dit by defining
# Maven JUnit SysProperties...
maven.junit.sysproperties=db.url db.user db.password db.driver db.seedfile
db.url=jdbc:mysql://localhost:3306/test
db.user=root
db.password=mypass
db.driver=com.mysql.jdbc.Driver
db.seedfile=/budget-seed.xml
thanx anyway and regards
marco
On 8/9/05, Marco Mistroni <mm...@gmail.com> wrote:
> Hello all,
> i am using Maven to build my project, but i am stuck with a problem.
> In running my tests, i would like to reuse inside my tests some
> properties defined in my project.properties.
> for example, i have to load a connection to a database (in my dbunit
> test), and i would like to pick databasename,user,password etc from
> project.properties.
>
> i have defined thos eproperties in project.properties, and in my
> dbunit file i am calling
> System.getProperty("db.user") for example
>
> but i get back null
>
> can anyone help me ou t?>
>
> thanx in advance and regards
> marco
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org