mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-12-27 19:07:28 +00:00
+ extracted datasource definition into a separate file to eliminate redundancy + introduce jdbc: namespace
37 lines
No EOL
1.9 KiB
XML
37 lines
No EOL
1.9 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
Application context definition for PetClinic Datasource.
|
|
-->
|
|
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xmlns:p="http://www.springframework.org/schema/p"
|
|
xmlns:context="http://www.springframework.org/schema/context"
|
|
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
|
xsi:schemaLocation="
|
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
|
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
|
|
|
|
<!-- ========================= DATASOURCE DEFINITION ========================= -->
|
|
|
|
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
|
|
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
|
|
<context:property-placeholder location="classpath:jdbc.properties"/>
|
|
|
|
<!-- DataSource configuration for Apache Commons DBCP. -->
|
|
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
|
|
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
|
|
p:username="${jdbc.username}" p:password="${jdbc.password}"/>
|
|
|
|
<!-- JNDI DataSource for JEE environments -->
|
|
<!--
|
|
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
|
-->
|
|
|
|
<!-- Database initializer. If any of the script fails, the initialization stops. -->
|
|
<!-- As an alternative, for embedded databases see <jdbc:embedded-database/>. -->
|
|
<jdbc:initialize-database data-source="dataSource">
|
|
<jdbc:script location="${jdbc.initLocation}"/>
|
|
<jdbc:script location="${jdbc.dataLocation}"/>
|
|
</jdbc:initialize-database>
|
|
|
|
</beans> |