mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch 'gh-4082'
This commit is contained in:
commit
45cad3c3b7
@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Dave Syer
|
||||
* @author Maciej Walkowiak
|
||||
* @author Stephane Nicoll
|
||||
* @author Benedikt Ritter
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = DataSourceProperties.PREFIX)
|
||||
@ -161,8 +162,8 @@ public class DataSourceProperties implements BeanClassLoaderAware, EnvironmentAw
|
||||
|
||||
public String getDriverClassName() {
|
||||
if (StringUtils.hasText(this.driverClassName)) {
|
||||
Assert.state(ClassUtils.isPresent(this.driverClassName, null),
|
||||
"Cannot load driver class: " + this.driverClassName);
|
||||
Assert.state(driverClassIsLoadable(), "Cannot load driver class: "
|
||||
+ this.driverClassName);
|
||||
return this.driverClassName;
|
||||
}
|
||||
String driverClassName = null;
|
||||
@ -182,6 +183,20 @@ public class DataSourceProperties implements BeanClassLoaderAware, EnvironmentAw
|
||||
return driverClassName;
|
||||
}
|
||||
|
||||
private boolean driverClassIsLoadable() {
|
||||
try {
|
||||
ClassUtils.forName(this.driverClassName, null);
|
||||
return true;
|
||||
}
|
||||
catch (UnsupportedClassVersionError ex) {
|
||||
// Driver library has been compiled with a later JDK, propagate error
|
||||
throw ex;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDriverClassName(String driverClassName) {
|
||||
this.driverClassName = driverClassName;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user