I recently created a new SpringBoot (version 3.0.6) project (via Initializr) and initially included some database-related dependencies. Now that I've gotten all of the fundamental functionality implemented, I realized that I don't actually need the app to directly interact with databases directly, so I wish to remove those dependencies.
I removed the obvious dependencies from my build.gradle
file:
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.integration:spring-integration-jpa'
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
Remaining dependencies include:
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-integration'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.integration:spring-integration-amqp'
implementation 'org.springframework.integration:spring-integration-http'
implementation 'org.springframework.integration:spring-integration-file'
implementation 'org.springframework.integration:spring-integration-mail'
implementation 'org.springframework.integration:spring-integration-security'
implementation 'org.apache.commons:commons-collections4:4.4'
implementation 'org.apache.commons:commons-lang3:3.12.0'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.amqp:spring-rabbit-test'
testImplementation 'org.springframework.integration:spring-integration-test'
testImplementation 'org.springframework.security:spring-security-test'
I also removed the database connection info from application.properties
:
server.servlet.context-path=/MyApp
instance.lock=false
#debug=false
spring.devtools.restart.log-condition-evaluation-delta=false
logging.level.org.me=debug
logging.level.org.springframework=info
logging.level.root=warn
server.ssl.enabled=false
server.port=8111
server.ssl.key-store=src/main/resources/server.jks
server.ssl.key-store-password=JohnDoe
server.ssl.key-password=blahblah
# TEST:
spring.rabbitmq.host=rmq-server
spring.rabbitmq.port=5671
spring.rabbitmq.username=messageUser
spring.rabbitmq.password=abc123
spring.rabbitmq.virtualhost=/vhost
spring.rabbitmq.ssl.enabled=true
spring.rabbitmq.my.request.queue=me.q.app.request
spring.rabbitmq.my.response.queue=me.q.app.response
Now when I start the app I'm seeing:
2023-05-18T14:16:32.376-05:00 WARN 29920 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
2023-05-18T14:16:32.429-05:00 INFO 29920 --- [ restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-05-18T14:16:32.453-05:00 ERROR 29920 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 0
Apparently something is still telling Spring that there should be a database, but I can't find where. Any suggestions on what else I need to remove in order to completely remove database-related dependencies would be appreciated.
I've tried doing various attempts at running gradle clean build --refresh-dependencies
, and rebuilding the project (in IntelliJ). I also started a new SpringBoot project with similar initial configuration to my app, but without the database dependencies, so that I could compare with my project, but was unable to find relevant differences.
When I run gradle dependencies
, nothing with "jdbc", "jpa", or "sql" was returned.