tree: 21bd1bf74e80d3cbd0ded6f35cbcf265c390b2b3 [path history] [tgz]
  1. .mvn/
  2. src/
  3. .gitignore
  4. mvnw
  5. mvnw.cmd
  6. pom.xml


Sample Application using H2 embedded database in spring boot


You should have the following installed 
 - Maven 
 - Tomcat

#Getting started

Create a sample Maven project with the following class DemoApplication

public class DemoApplication {

	// Start of a spring boot app
	public static void main(String[] args) {, args);

The H2 database is taken as default (configuration file is not required in this case), so just we need to give its dependencies in the pom file

Add the following dependencies to your POM file


Make a sample sql statements file and give the following in the main application to run the script

// Gets the sql statements from init.sql
	private Resource initSqlScript;

	// Sql statements are executed
	public CommandLineRunner init(DataSource ds) {
		return args -> {
			ScriptUtils.executeSqlScript(ds.getConnection(), initSqlScript);

Add the model, controllers and Repositories to the code and do a maven build in eclipse or in the command prompt as follows:

mvn clean install

Run the application as spring-boot app using the following command

mvn spring-boot:run