Spring Framework กับการใช้งาน config file ด้วย PropertyPlaceholderConfigurer
บทความเกี่ยวกับ : Spring Framework กับการใช้งาน config file ด้วย PropertyPlaceholderConfigurer บางงานผมจำเป็นต้องมีการเก็บค่าบางอย่างลงใน Properties file เพื่อเป็น Configuration ไว้ใช้งานในระบบ วิธีการของผมคือ ผมจะวางไฟล์ นี้ไว้ใน Class Path หรือ หัอง SRC จากนั้นทำกาน Load file นี้ขึ้นมาใช้ได้ด้วย PropertyPlaceholderConfigurer ตามตัวอย่าง <!-- Spring properties file config --> <bean name="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath*:db.properties</value> </list> </property> </bean> จากตัวอย่าง ผมมีไฟล์ชื่อว่า db.properties วางไว้ใน class path สาเหตุที่วางไว้ในนี้เพราะจะได้ไม่ต้องระบุ Path ให้ยุ่งยากจากนั้นเวลาใช้ก็แค่เรียกใช้งานตาม tag ดังนี้ <bean id="dataSource" class=&qu