1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <beans xmlns="http://www.springframework.org/schema/beans"
\r
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
\r
4 xmlns:util="http://www.springframework.org/schema/util"
\r
5 xmlns:tx="http://www.springframework.org/schema/tx"
\r
6 xmlns:jee="http://www.springframework.org/schema/jee"
\r
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
\r
8 http://www.springframework.org/schema/beans/spring-beans.xsd
\r
9 http://www.springframework.org/schema/util
\r
10 http://www.springframework.org/schema/util/spring-util.xsd
\r
11 http://www.springframework.org/schema/tx
\r
12 http://www.springframework.org/schema/tx/spring-tx.xsd
\r
13 http://www.springframework.org/schema/jee
\r
14 http://www.springframework.org/schema/jee/spring-jee.xsd">
\r
18 In this way we can not use all the available options for H2.
\r
20 Because of that I will be using the dataSource bean where I can choose as many options
\r
22 <jdbc:embedded-database id="dataSource" type="H2" />
\r
26 1. There are two beans with the same id "dataSource"
\r
27 One declared in datasource-configuration.xml
\r
28 Another one declared in datasource-test-configuration.xml
\r
29 2. Both beans are declared in different XML files.
\r
30 3. Because there are in different XML files Spring does not complain about having duplicate beans.
\r
31 4. Because files in src/test will be loaded in class path after files in src/main this bean will
\r
32 override the one declared in datasource-configuration.xml when running JUnit Tests :)
\r
34 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
\r
35 <property name="driverClassName" value="org.h2.Driver" />
\r
36 <property name="url" value="jdbc:h2:mem:mybatis_example;INIT=create schema if not exists mybatis_example\;SET SCHEMA mybatis_example;MODE=MySQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" />
\r
37 <property name="username" value="mybatis" />
\r
38 <property name="password" value="" />
\r