schema.sql: This is the data model for the SpringBlog application.
1.
schema-h2.sql: This is the schema for the tables required by Spring Batch.
2.
initial-data.sql: This is the initial data (users, roles, categories, and so on)
3.
for the SpringBlog application.
To set up MySQL, as shown in the dataSource bean definition for the mysql profile, in MySQL, set up
a database called springblog and then a user with the user name and password both set to springblog (or
you can change the datasource settings based on your preference). You then need to run the three scripts
(schema.sql, schema-mysql.sql, initial-data.sql) in the folder /src/main/resources/sql, respectively.
Note that the file schema-mysql.sql is for the creation of Spring Batch tables.
Next, we need to modify the active profile of Spring's WebApplicationContext to use the dataSource
bean for MySQL. To change the active profile, we need to modify the setting in the web deployment
descriptor file (/WEB-INF/web.xml), as in the code snippet shown in Listing 21-2.
Listing 21-2. Changing the Active Profile in the web.xml File
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<!-- Enable escaping of form submission contents -->
<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.active</param-name>
<!-- Spring profile parameters
First profile: jpa - JPA implementation
mybatis - MyBatis implementation
Second profile: mysql - MySQL DB
h2 - H2 database
-->
<param-value>jpa,h2</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/root-context.xml
/WEB-INF/spring/datasource.xml
/WEB-INF/spring/batch-context.xml
/WEB-INF/spring/*-tx-config.xml
/WEB-INF/spring/*-service-context.xml
</param-value>
</context-param>
<!-- Other code omitted -->
</web-app>
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home