How to read values from properties file?

Configure PropertyPlaceholder in your context: <context:property-placeholder location=”classpath*:my.properties”/> Then you refer to the properties in your beans: @Component class MyClass { @Value(“${my.property.name}”) private String[] myValues; } To parse property with multiple comma-separated values: my.property.name=aaa,bbb,ccc If that doesn’t work, you can define a bean with properties, inject and process it manually: <bean id=”myProperties” class=”org.springframework.beans.factory.config.PropertiesFactoryBean”> <property name=”locations”> <list> … Read more

Where to place and how to read configuration resource files in servlet based application?

It’s your choice. There are basically three ways in a Java web application archive (WAR): 1. Put it in classpath So that you can load it by ClassLoader#getResourceAsStream() with a classpath-relative path: ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream input = classLoader.getResourceAsStream(“foo.properties”); // … Properties properties = new Properties(); properties.load(input); Here foo.properties is supposed to be placed … Read more

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