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
17 1. There are two beans with the same id "dataSource"
\r
18 One declared in datasource-configuration.xml
\r
19 Another one declared in datasource-test-configuration.xml
\r
20 2. Both beans are declared in different XML files.
\r
21 3. Because there are in different XML files Spring does not complain about having duplicate beans.
\r
22 4. Because files in src/test will be loaded in class path after files in src/main this bean will
\r
23 override the one declared in datasource-configuration.xml when running JUnit Tests :)
\r
25 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
\r
26 <property name="driverClassName" value="com.mysql.cj.jdbc.Driver" />
\r
28 <!-- DATABASE_PORT should be a system or environment property
\r
29 If running tests from the IDE, we must configure JUnit for using
\r
30 this property with the right value.
\r
32 It is useful if we want to run just one test from our IDE but it requires
\r
33 to have a database always running.
\r
35 There is no collision with gradle integTest command because docker-compose is using
\r
36 a random port. So we can run tests one by one from our IDE (but it requires database running)
\r
37 and also run our tests from the command console by means of gradle integTest (it will
\r
38 start a new data base in a random and available port)
\r
39 This feature is also required by systems like Travis where we do not control the available ports.
\r
41 <property name="url" value="jdbc:mysql://127.0.0.1:{DATABASE_PORT}/mybatis_example?createDatabaseIfNotExist=true&allowMultiQueries=true&autoReconnect=true&characterEncoding=UTF-8" />
\r
42 <property name="username" value="root" />
\r
43 <property name="password" value="root" />
\r