Auto-configure Flyway and Liquibase when there's a URL but no DataSource
See gh-16850pull/17002/head
parent
f59e337aba
commit
3ca73bf00d
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.flyway;
|
||||
|
||||
/**
|
||||
* Exception thrown when no Flyway is enabled and present in classpath but no datasource
|
||||
* was available or configured for it.
|
||||
*
|
||||
* @author Ilya Lukyanovich
|
||||
*/
|
||||
public class FlywayDataSourceMissingException extends RuntimeException {
|
||||
|
||||
FlywayDataSourceMissingException() {
|
||||
super("Flyway is present in classpath and enabled but "
|
||||
+ "no DataSource bean neither " + FlywayProperties.PROPERTIES_PREFIX
|
||||
+ ".url and " + FlywayProperties.PROPERTIES_PREFIX
|
||||
+ ".user configuration was provided");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.flyway;
|
||||
|
||||
import org.springframework.boot.diagnostics.AbstractFailureAnalyzer;
|
||||
import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||
|
||||
/**
|
||||
* A {@code FailureAnalyzer} that performs analysis of failures caused by a
|
||||
* {@link FlywayDataSourceMissingException}.
|
||||
*
|
||||
* @author Ilya Lukyanovich
|
||||
*/
|
||||
class FlywayDataSourceMissingFailureAnalyzer
|
||||
extends AbstractFailureAnalyzer<FlywayDataSourceMissingException> {
|
||||
|
||||
@Override
|
||||
protected FailureAnalysis analyze(Throwable rootFailure,
|
||||
FlywayDataSourceMissingException cause) {
|
||||
return new FailureAnalysis("No DataSource found for flyway",
|
||||
"Please provide a javax.sql.DataSource bean or flyway datasource configuration",
|
||||
cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.liquibase;
|
||||
|
||||
/**
|
||||
* Exception thrown when Liquibase is enabled and present in classpath but no datasource
|
||||
* was available or configured for it.
|
||||
*
|
||||
* @author Ilya Lukyanovich
|
||||
*/
|
||||
public class LiquibaseDataSourceMissingException extends RuntimeException {
|
||||
|
||||
LiquibaseDataSourceMissingException() {
|
||||
super("Liquibase is present in classpath and enabled but "
|
||||
+ "no DataSource bean neither " + LiquibaseProperties.PROPERTIES_PREFIX
|
||||
+ ".url and " + LiquibaseProperties.PROPERTIES_PREFIX
|
||||
+ ".user configuration was provided");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.liquibase;
|
||||
|
||||
import org.springframework.boot.diagnostics.AbstractFailureAnalyzer;
|
||||
import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||
|
||||
/**
|
||||
* A {@code FailureAnalyzer} that performs analysis of failures caused by a
|
||||
* {@link LiquibaseDataSourceMissingException}.
|
||||
*
|
||||
* @author Ilya Lukyanovich
|
||||
*/
|
||||
class LiquibaseDataSourceMissingFailureAnalyzer
|
||||
extends AbstractFailureAnalyzer<LiquibaseDataSourceMissingException> {
|
||||
|
||||
@Override
|
||||
protected FailureAnalysis analyze(Throwable rootFailure,
|
||||
LiquibaseDataSourceMissingException cause) {
|
||||
return new FailureAnalysis("No DataSource found for liquibsae",
|
||||
"Please provide a javax.sql.DataSource bean or liquibase datasource configuration",
|
||||
cause);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue