Sunday, March 20, 2011

Spring : Using the P namespace


Similarily we can configure our db-config.xml file in a different way:
Example using the property p Namespace
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
    xmlns:p="http://www.springframework.org/schema/p">

     <bean id="myDataSource" 
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
        p:driverClassName="com.mysql.jdbc.Driver"
        p:url="jdbc:mysql://localhost:3306/test"
        p:username="root"
        p:password=""/>

</beans>
clearly p namespace reduces the xml we have to write, instead of writing so much, we have to write less and that too in the clear way.

No comments:

Post a Comment

Chitika