I have spring boot application which use 2 databases. I defined 2 configurations providing specified datasources. I want to have that datasources managed separately by liquibase. I defined 2 separated changelog files.
The problem is that I can't define 2 separate beans for liquibase.
Here are my config classes:
...
public class CCSConfiguration {
...
#Bean
#ConfigurationProperties("ccs.liquibase")
public LiquibaseProperties ccsLiquibaseProperties() {
return new LiquibaseProperties();
}
#Bean
public SpringLiquibase ccsLiquibase(LiquibaseProperties liquibaseProperties) {
...
}
...
}
...
public class CCAConfiguration {
...
#ConfigurationProperties("cca.liquibase")
public LiquibaseProperties ccaLiquibaseProperties() {
return new LiquibaseProperties();
}
#Bean
public SpringLiquibase ccaLiquibase(LiquibaseProperties liquibaseProperties) {
...
}
...
}
And properties:
cca:
liquibase:
change-log: classpath:config/liquibase/cca/master.xml
ccs:
liquibase:
change-log: classpath:config/liquibase/ccs/master.xml
With this config i get following error while running appliction:
2017-04-11 14:26:55.664 WARN 34292 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'liquibase' available
2017-04-11 14:26:55.711 WARN 34292 --- [ restartedMain] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.config.internalCacheAdvisor' defined in class path resource [org/springframework/cache/annotation/ProxyCachingConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor]: Factory method 'cacheAdvisor' threw exception; nested exception is java.lang.NullPointerException)
2017-04-11 14:26:55.939 ERROR 34292 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean named 'liquibase' that could not be found.
Action:
Consider defining a bean named 'liquibase' in your configuration.
So, is it possible to define multiple liquibase beans for different datasources?
there are two options:
you define a bean named liquibase to let spring-boot integrated process to update your schema on you first DS. You have to handle the second one by hand
you disable liquibase automatic update at startup with
enabled: false
and define your way DS and liquibase beans to update your two databases
Related
Startup error
2020-11-06 18:07:31.452 WARN 13120 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.maple.MapleApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'a' for bean class [com.maple.a.d.a.a] conflicts with existing, non-compatible bean definition of same name and class [com.maple.a.b.a]
2020-11-06 18:07:31.463 ERROR 13120 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.maple.MapleApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'a' for bean class [com.maple.a.d.a.a] conflicts with existing, non-compatible bean definition of same name and class [com.maple.a.b.a]
I tried to use Spring definition.getBeanClassName() naming rules, but it didn’t work. Is it too much trouble if you want to manually set the name of each bean on the annotation? Can ProGuard provide the function of not repeating the class name? I haven’t found it yet.
I'm doing a MVC project with spring boot and spring security and jsp. I'm just training my spring and I have the same project running without spring boot. Currently I moved to springboot and when I try to start I get :
2020-05-09 17:28:38.521 INFO 21308 --- [ restartedMain]
o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring
embedded WebApplicationContext 2020-05-09 17:28:38.527 INFO 21308 ---
[ restartedMain] o.s.web.context.ContextLoader : Root
WebApplicationContext: initialization completed in 6813 ms 2020-05-09
17:28:38.753 WARN 21308 --- [ restartedMain]
ConfigServletWebServerApplicationContext : Exception encountered
during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'inMemoryDatabaseShutdownExecutor'
defined in class path resource
[org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]:
Unsatisfied dependency expressed through method
'inMemoryDatabaseShutdownExecutor' parameter 0; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource' defined in class path resource
[org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method
'dataSource' threw exception; nested exception is
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException:
Failed to determine a suitable driver class 2020-05-09 17:28:38.769
INFO 21308 --- [ restartedMain]
o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-05-09 17:28:38.826 INFO 21308 --- [ restartedMain]
ConditionEvaluationReportLoggingListener :
*************************** APPLICATION FAILED TO START
Description:
Failed to configure a DataSource: 'url' attribute is not specified and
no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
I have no idea what is happening.
application.properties
# JDBC properties
#
app.datasource.url=jdbc:mysql://localhost:3306/web_customer_tracker?useSSL=false&serverTimezone=UTC
app.datasource.username=springstudent
app.datasource.password=springstudent
# Spring Data JPA properties
spring.data.jpa.repository.packages=com.crm.dao
spring.data.jpa.entity.packages-to-scan=com.crm.beans
#
# SECURITY JDBC properties
#
security.datasource.jdbc-url=jdbc:mysql://localhost:3306/spring_security_demo_bcrypt?useSSL=false&serverTimezone=UTC
security.datasource.username=springstudent
security.datasource.password=springstudent
security.datasource.driver-class-name= com.mysql.jdbc.Driver
Configuration:
#Configuration
#EnableWebSecurity
public class DemoSecurityConfig extends WebSecurityConfigurerAdapter {
// add a reference to our security data source
#Autowired
#Qualifier("securityDataSource")
private DataSource securityDataSource;
#Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(securityDataSource);
}
#Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/resources/**");
}
#Override
protected void configure(HttpSecurity http) throws Exception {
System.out.println("aplicando configuracion");
http.authorizeRequests()
.antMatchers("/employees/showForm*").hasAnyRole("MANAGER", "ADMIN")
.antMatchers("/employees/save*").hasAnyRole("MANAGER", "ADMIN")
.antMatchers("/employees/delete").hasRole("ADMIN")
.antMatchers("/employees/**").hasRole("EMPLOYEE")
.antMatchers("/resources/**").permitAll()
.antMatchers("/showMyLoginPage").permitAll()
.and()
.formLogin()
.loginPage("/showMyLoginPage")
.loginProcessingUrl("/authenticateTheUser")
.permitAll()
.and()
.logout().permitAll()
.and()
.exceptionHandling().accessDeniedPage("/access-denied");
}
}
Configuration:
#Configuration
#EnableJpaRepositories(basePackages={"${spring.data.jpa.repository.packages}"})
public class DemoDataSourceConfig {
#Primary
#Bean
#ConfigurationProperties(prefix="app.datasource")
public DataSource appDataSource() {
return DataSourceBuilder.create().build();
}
#Bean
#ConfigurationProperties(prefix="spring.data.jpa.entity")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, DataSource appDataSource) {
return builder
.dataSource(appDataSource)
.build();
}
#Bean
#ConfigurationProperties(prefix="security.datasource")
public DataSource securityDataSource() {
return DataSourceBuilder.create().build();
}
}
Thanks for your help in advance.
In your properties file...
Change app.datasource.* to spring.datasource.* like below..
# JDBC properties
#
spring.datasource.url=jdbc:mysql://localhost:3306/web_customer_tracker?useSSL=false&serverTimezone=UTC
spring.datasource.username=springstudent
spring.datasource.password=springstudent
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
This error message gives hint that when Soring looks for database URL property.. (they have a fixed property name for it.. like spring.datasource.*) Or Else.. if you are using any embedded database like DB2 then it does not require any url/username/password only the dependency is enough.
In your case, it's not embedded database.. so the property name spring looks for, must be provided correctly.
I am trying to upload my application spring boot on jenkins, try to exclude #EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
classes with
but continues to show the error
I'm using
gradle
buildscript {
ext {
DEPENDENCY_MANAGEMENT_VERSION = '1.0.6.RELEASE'
SPRING_BOOT_VERSION = '2.2.2.RELEASE'
SONARQUBE_VERSION = '2.6.1'
DEPENDENCY_CHECK_VERSION = '2.0.0'
}
repositories {
maven {
url "${artifactory_contextUrl}/virtual-release-bns"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
flatDir {
dirs "libs"
}
}
dependencies {
classpath("io.spring.gradle:dependency-management-plugin:${DEPENDENCY_MANAGEMENT_VERSION}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${SPRING_BOOT_VERSION}")
classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${SONARQUBE_VERSION}")
classpath("org.owasp:dependency-check-gradle:${DEPENDENCY_CHECK_VERSION}")
}
}
apply plugin: 'org.sonarqube'
apply plugin: 'org.springframework.boot'
apply plugin: 'org.owasp.dependencycheck'
/* -------------------------------- */
/* - Include other gradle scripts - */
/* -------------------------------- */
def gradlePath = "${rootProject.projectDir}${project.property('gradle.path')}"
apply from: "${gradlePath}/libraries.gradle"
apply from: "${gradlePath}/build-config.gradle"
apply from: "${gradlePath}/build-java.gradle"
apply from: "${gradlePath}/build-report.gradle"
apply from: "${gradlePath}/build-sonar.gradle"
apply from: "${gradlePath}/build-dependencycheck.gradle"
apply from: "${gradlePath}/build-dependencies.gradle"
apply from: "${gradlePath}/build-spring-conf.gradle"
apply from: "${gradlePath}/build-plato.gradle"
allprojects {
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:${SPRING_BOOT_VERSION}")
}
}
}
file Application.properties
# ============================================================================
# Parameter Properties for project 'prueba pr'
# ============================================================================
# Properties
# Only allow properties that are environment independent
# The application.properties name is changed to avoid environment conflict
# ============================================================================
# Application name, different context
spring.application.name=prueba
spring.mvc.locale=es_ES
# Avoid error 405 with spring information
spring.mvc.throw-exception-if-no-handler-found=true
spring.resources.add-mappings=false
# Allow that spring interceptor does not filter option
spring.mvc.dispatch-options-request=true
# static resources location
#spring.resources.static-locations=classpath:/webapp
# Application name, different context
server.port=9980
server.contextPath=/dotrx
spring.application.name=dotrx
spring.application.profiles=dev
spring.profiles=dev
spring.profiles.active=dev
# JMX Actuator
spring.jmx.default-domain=fg
endpoints.jmx.domain=fg
endpoints.jmx.unique-name=true
# JMX Actuator deactivate endpoint
endpoints.trace.enabled=false
endpoints.shutdown.enabled=false
endpoints.info.enabled=false
endpoints.flyway.enabled=false
endpoints.mappings.enabled=false
endpoints.dump.enabled=false
endpoints.docs.enabled=false
endpoints.configprops.enabled=false
endpoints.autoconfig.enabled=false
endpoints.auditevents.enabled=false
endpoints.env.enabled=false
endpoints.heapdump.enabled=false
endpoints.loggers.enabled=false
endpoints.metrics.enabled=false
endpoints.beans.enabled=false
# Datasouces JNDI
sybase.datasource.jndi-name=jdbc/DSSYB_CLDC101
#OAuth
app.token.secret=fg
#Adm Token
app.adm.token.secret=123
f89a06
# Atr Properties
atr.socket.numsession=50
# JSON config folder in classpath
rcfg.json.folder=conf
# JSON i18n texts backoffice
backoffice.file.path=i18n/cms-backoffice.json
# fg Variables
gf.atr.service=CLDC124.uatchl.bns,6100
fg.atr.timeout=60
# fg SYBASE
fg.datasource.url=jdbc:sybase:360
fg.datasource.driverclassname=com.sybase.jdbc4.jdbc.SybDataSource
fg.datasource.username=admin
fg.datasource.pass=123
#Loggable Properties
loggable.system.log.name=SystemOut
loggable.error.log.name=ErrorOut
#Transactional Logger
logger.namespace=fg
logger.token.header=Authorization
logger.token.signature=fg
logger.token.claims.userRut=user.key
logger.token.claims.clientRut=enterprise.key
logger.writing.endpoint=http://123.com
logger.writing.alg=HS256
logger.writing.typ=Authorization
logger.writing.signature=MSLOGGER
logger.writing.expiration=900
logger.pathfile=./controller-dotrx/src/main/resources/logger.json
log.error=exceptions
ERROR
c.s.d.p.mapper.config.SybaseDBConfig : SybaseDBConfig getDataSource end
2020-02-07 10:08:37.216 ERROR 9616 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthContributorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributor]: Factory method 'dbHealthContributor' threw exception; nested exception is java.lang.IllegalArgumentException: Beans must not be empty
2020-02-07 10:08:37.247 INFO 9616 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-02-07 10:08:37.263 WARN 9616 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-02-07 10:08:37.263 INFO 9616 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-02-07 10:08:37.303 ERROR 9616 --- [ main] o.s.boot.SpringApplication : Application run failed
does Spring Boot wraps/hides/encapsulates exceptions one way or another ?
I get some strange behaviour when an exception is produced.
For instance, in a Spring Boot + JPA project, if i comment out the #Entity annotation :
#Table(name = "XXX")
//#Entity
public class Contract
{
...
}
i get the following exception (warning) :
2018-12-10 19:09:33.153 DEBUG DESKTOP-48HHHCD --- [ost-startStop-1] o.h.c.CollectionSecondPass : Second pass for collection: cp.dmo.bean.ContribuablePar.listeContratMensu
2018-12-10 19:09:33.153 DEBUG DESKTOP-48HHHCD --- [ost-startStop-1] o.h.c.a.CollectionBinder : Binding a collection of element: cp.dmo.bean.ContribuablePar.listeContratMensu
2018-12-10 19:09:33.154 WARN DESKTOP-48HHHCD --- [ost-startStop-1] o.s.b.f.s.DefaultListableBeanFactory : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testpopulationserviceso' defined in file [C:\Users\celfer\AppData\Local\Temp\1-dmo\WEB-INF\classes\conf\application\applicationContext-service.xml]: Cannot resolve reference to bean 'testpopulationserviceimpl' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testpopulationserviceimpl' defined in file [C:\Users\celfer\AppData\Local\Temp\1-dmo\WEB-INF\classes\conf\application\applicationContext-service.xml]: Cannot resolve reference to bean 'testpopulationdao' while setting bean property 'testpopulationdao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testpopulationdao' defined in file [C:\Users\celfer\AppData\Local\Temp\1-dmo\WEB-INF\classes\conf\application\applicationContext-dao.xml]: Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in URL [jar:file:/C:/Users/celfer/AppData/Local/Temp/1-dmo/WEB-INF/lib/lombok-jpa-24.0.6-SNAPSHOT.jar!/conf/applicationContext-datasources-jpa2.xml]: Cannot resolve reference to bean 'entityManager' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManager' defined in URL [jar:file:/C:/Users/celfer/AppData/Local/Temp/1-dmo/WEB-INF/lib/lombok-jpa-24.0.6-SNAPSHOT.jar!/conf/applicationContext-datasources-jpa2.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2018-12-10 19:09:33.155 DEBUG DESKTOP-48HHHCD --- [ost- startStop-1] o.s.b.f.s.DefaultListableBeanFactory : Creating shared instance of singleton bean 'lecturepersonneso'
So the exception says the application is unable to build a Hibernate SessionFactory but it does not point out precisely where the problem comes from.
Any clue ?
Thanks
I went back to programming my old program https://github.com/JonkiPro/REST-Web-Services. I've updated Spring Boot from version 15.6 to version 2.0.0. I have encountered many problems with compilation, but I can not deal with one. Well, during compilation, he throws me in the console
2018-03-18 21:54:53.339 ERROR 3220 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig : HikariPool-1 - jdbcUrl is required with driverClassName.
2018-03-18 21:54:55.392 INFO 3220 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'unit'
2018-03-18 21:54:56.698 INFO 3220 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'unit'
2018-03-18 21:54:56.778 ERROR 3220 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig : HikariPool-1 - jdbcUrl is required with driverClassName.
2018-03-18 21:54:56.782 ERROR 3220 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService' defined in file [C:\Users\Jonatan\Documents\GitHub\REST-Web-Services\web\out\production\classes\com\web\web\security\service\impl\UserDetailsServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#65d6e77b' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#65d6e77b': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
2018-03-18 21:54:56.821 WARN 3220 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
I've never had such a mistake. I do not know what it means completely. My properties for the base look like this
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql:database
username: root
password: root
schema: classpath:/db/init/schema.sql
I do not know how to deal with this error. I've been programming quite a long time, but for the first time I'm meeting the concept of hikari. I'm using a Tomcat(in Spring Boot) server and a PostgreSQL database.
I had the same issue in another context.
From the 79. Data Access - Configure a Custom DataSource
if you happen to have Hikari on the classpath, this basic setup does not work, because Hikari has no url property (but does have a jdbcUrl property)
Hikari is the default pool in spring boot 2.
so you can replace the config
url: jdbc:postgresql:database -> jdbc-url: jdbc:postgresql:database
or you can keep the config but you need to define another Bean to handle the mapping (aliases)
#Bean
#Primary
#ConfigurationProperties("app.datasource")
public DataSourceProperties dataSourceProperties() {
return new DataSourceProperties();
}
#Bean
#ConfigurationProperties("app.datasource")
public DataSource dataSource(DataSourceProperties properties) {
return properties.initializeDataSourceBuilder().
.build();
}
Either remove spring.datasource.driver-class-name property or rename the spring.datasource.url property to spring.datasource.jdbc-url.
This is reported in your error:
java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName
First option looks cleaner and Spring Boot will figure out the default driver class name based on the spring.datasource.url property value (see org.springframework.boot.jdbc.DatabaseDriver class if you want to debug this).