Read a properties file in powershell

You can use ConvertFrom-StringData to convert Key=Value pairs to a hash table: $filedata = @’ app.name=Test App app.version=1.2 ‘@ $filedata | set-content appdata.txt $AppProps = convertfrom-stringdata (get-content ./appdata.txt -raw) $AppProps Name Value —- —– app.version 1.2 app.name Test App $AppProps.’app.version’ 1.2

Reading properties file from Maven POM file

Maven allows you to define properties in the project’s POM. You can do this using a POM file similar to the following: <project> … <properties> <server.url>http://localhost:8080/manager/html</server.url> </properties> … <build> <plugins> <plugin> … <configuration> <url>${server.url}</url> <server>tomcat</server> </configuration> … </plugin> </plugins> </build> </project> You can avoid specifying the property within the properties tag, and pass the value … Read more

Get int, float, boolean and string from Properties

If you have a class of configuration values, like your Constants class, and you want to load all values from a configuration (properties) file, you can create a little helper class and use reflection: public class ConfigLoader { public static void load(Class<?> configClass, String file) { try { Properties props = new Properties(); try (FileInputStream … Read more

adding comment in .properties files

The property file task is for editing properties files. It contains all sorts of nice features that allow you to modify entries. For example: <propertyfile file=”build.properties”> <entry key=”build_number” type=”int” operation=”+” value=”1″/> </propertyfile> I’ve incremented my build_number by one. I have no idea what the value was, but it’s now one greater than what it was … Read more

How to use YamlPropertiesFactoryBean to load YAML files using Spring Framework 4.1?

With XML config I’ve been using this construct: <context:annotation-config/> <bean id=”yamlProperties” class=”org.springframework.beans.factory.config.YamlPropertiesFactoryBean”> <property name=”resources” value=”classpath:test.yml”/> </bean> <context:property-placeholder properties-ref=”yamlProperties”/> Of course you have to have the snakeyaml dependency on your runtime classpath. I prefer XML config over the java config, but I recon it shouldn’t be hard to convert it. edit: java config for completeness sake … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)