diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java index 17ef8fdaec6..e8f76ffe121 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import org.springframework.util.StringUtils; * * @author Dave Syer * @author Phillip Webb + * @author Eddú Meléndez * @since 1.1.0 * @see DataSourceAutoConfiguration */ @@ -78,7 +79,9 @@ class DataSourceInitializer implements ApplicationListener scripts = getScripts(this.properties.getSchema(), "schema"); if (!scripts.isEmpty()) { - runScripts(scripts); + String username = this.properties.getSchemaUsername(); + String password = this.properties.getSchemaPassword(); + runScripts(scripts, username, password); try { this.applicationContext .publishEvent(new DataSourceInitializedEvent(this.dataSource)); @@ -111,7 +114,9 @@ class DataSourceInitializer implements ApplicationListener scripts = getScripts(this.properties.getData(), "data"); - runScripts(scripts); + String username = this.properties.getDataUsername(); + String password = this.properties.getDataPassword(); + runScripts(scripts, username, password); } private List getScripts(String locations, String fallback) { @@ -141,7 +146,7 @@ class DataSourceInitializer implements ApplicationListener resources) { + private void runScripts(List resources, String username, String password) { if (resources.isEmpty()) { return; } @@ -154,7 +159,14 @@ class DataSourceInitializer implements ApplicationListener