Skip to content

Commit ad87a76

Browse files
committed
Add check for missing Liquibase's class CustomResolverServiceLocator
`CustomResolverServiceLocator` was introduced in Liquibase 2.0.4, this check prevents failures during initialization when previous versions are used. See spring-projectsgh-11608
1 parent 84fa67d commit ad87a76

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

spring-boot/src/main/java/org/springframework/boot/liquibase/LiquibaseServiceLocatorApplicationListener.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*
3232
* @author Phillip Webb
3333
* @author Dave Syer
34+
* @author Eddú Meléndez
3435
*/
3536
public class LiquibaseServiceLocatorApplicationListener
3637
implements ApplicationListener<ApplicationStartingEvent> {
@@ -51,12 +52,14 @@ public void onApplicationEvent(ApplicationStartingEvent event) {
5152
private static class LiquibasePresent {
5253

5354
public void replaceServiceLocator() {
54-
CustomResolverServiceLocator customResolverServiceLocator = new CustomResolverServiceLocator(
55-
new SpringPackageScanClassResolver(logger));
56-
customResolverServiceLocator.addPackageToScan(
57-
CommonsLoggingLiquibaseLogger.class.getPackage().getName());
58-
ServiceLocator.setInstance(customResolverServiceLocator);
59-
liquibase.logging.LogFactory.reset();
55+
if (ClassUtils.isPresent("liquibase.servicelocator.CustomResolverServiceLocator", null)) {
56+
CustomResolverServiceLocator customResolverServiceLocator = new CustomResolverServiceLocator(
57+
new SpringPackageScanClassResolver(logger));
58+
customResolverServiceLocator.addPackageToScan(
59+
CommonsLoggingLiquibaseLogger.class.getPackage().getName());
60+
ServiceLocator.setInstance(customResolverServiceLocator);
61+
liquibase.logging.LogFactory.reset();
62+
}
6063
}
6164

6265
}

0 commit comments

Comments
 (0)