25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 19 ■ <strong>Spring</strong> Boot, Simplifying Everything<br />

t.name as type_name, t.description as type_desc, t.extension from<br />

documents d<br />

join types t<br />

on d.typeId = t.typeId<br />

where t.name = ?<br />

<br />

<br />

<br />

<br />

insert into documents (documentId,name,location,description, typeId,<br />

created, modified)<br />

values (?,?,?,?,?,?,?)<br />

<br />

<br />

<br />

<br />

update documents set name = ?, location = ?, description = ?, typeId =<br />

?,modified = ?<br />

where documentId = ?<br />

<br />

<br />

<br />

<br />

delete from documents<br />

where documentId = ?<br />

<br />

<br />

<br />

<br />

<br />

<br />

Now, let’s create the main <strong>Spring</strong> Boot application that will bootstrap everything and run the application in an<br />

embedded web server, as shown in Listing 19-4.<br />

Listing 19-4. MyDocumentsApp.java<br />

package com.apress.isf.spring.boot;<br />

import javax.sql.DataSource;<br />

import org.springframework.boot.<strong>Spring</strong>Application;<br />

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;<br />

import org.springframework.context.annotation.Bean;<br />

import org.springframework.context.annotation.ComponentScan;<br />

import org.springframework.context.annotation.Configuration;<br />

import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;<br />

import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;<br />

import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;<br />

266

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!