<bean id="mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties">
<value>
jdbc.driver.className=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mydb
value>
property>
bean>
Learn and Share about AI, GenAI, AEM, Angular, React, Tailwind, Mobile Development, Node.js, MicroServices and Cloud
-- ideas can change everything!
<bean id="mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties">
<value>
jdbc.driver.className=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mydb
value>
property>
bean>
xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<bean id="propertyHolder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" scope="singleton" lazy-init="false">
<property name="locations">
<value>
classpath:data.properties
value>
property>
bean>
<bean id="sayHello" class="com.surya.mybeans.HelloSpringBean" depends-on="propertyHolder">
<property name="userName" value="${user.name}" />
bean>
beans>
xml version="1.0" encoding="UTF-8"?>
package com.surya.mybeans;
public class HelloSpringBean {
private String userName;
public void sayHello() {
System.out.print("I am " + userName+ " ! Saying Hello to Spring world");
}
public void setUserName(String userName) {
this.userName = userName;
}
}
package com.surya.application.init;
import com.surya.mybeans.HelloSpringBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class ApplicationInitlizer {
public static void main(String...strings ){
try{
ApplicationContext xmlBf=new ClassPathXmlApplicationContext("application-context.xml");
((HelloSpringBean)xmlBf.getBean("sayHello")).sayHello();
}catch(Exception ex ){
ex.printStackTrace();
}
}
}
Have you ever felt "in the zone" while coding? That feeling of seamless flow, where the code practically writes itself? That's...