java - how to configure a maven project to read from a config.properties file? -
i have servlet dao class has following constructor:
public dao() { env = new hashtable<string, string>(); env.put(context.initial_context_factory, "com.sun.jndi.ldap.ldapctxfactory"); env.put(context.provider_url, "ldap://localhost:1389"); env.put(context.security_authentication, "simple"); env.put(context.security_principal, "cn=directory manager"); env.put(context.security_credentials, "secret"); }
i've written following config.properties file in source/main/resources :
initial_context_factory=com.sun.jndi.ldap.ldapctxfactory provider_url=ldap://localhost:1389 security_authentication=simple security_principal=cn=directory manager security_credentials=secret
how configure pom.xml file tell maven use config.properties ?
here, resolved adding plugin block:
<plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>properties-maven-plugin</artifactid> <version>1.0-alpha-2</version> <executions> <execution> <phase>initialize</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>${basedir}/src/main/resources/config.properties</file> </files> </configuration> </execution> </executions> </plugin>
Comments
Post a Comment