1

Please note: this question is not a dupe, and I even reference the other similar question below. I assert that my situation is categorically different than the other question referenced.


I am standing up a Spring Boot web service that is not backed by any database, JDBC or RDBMS data source.

At startup I get and error:

Cannot determine embedded database driver class for database type NONE

Here on SO I see a very similar question here where the accepted answer states:

"You haven't provided Spring Boot with enough information to auto-configure a DataSource"

...and goes on to explain how to set the appropriate values in the app config file:

spring.datasource.url = ...
spring.datasource.driver-class-name = ...

But what if I don't want any data sources?! In the other question, the user was connecting to NoSQL via DataNucleus. In my case, I'm not interested (at least at the present moment) in connecting to any type of data source (all data for this service will come from other cloud-based REST services).

What's the fix here?

hotmeatballsoup
  • 385
  • 6
  • 58
  • 136

2 Answers2

4

According to the documentation, you can turn this behavior off by excluding DataSourceAutoConfiguration from the auto-configuration that Spring Boot does for you.

@Configuration
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class MyConfiguration {
    // ...
}

Update To Answer Questions: By using @SpringBootApplication, it automatically pulls in @EnableAutoConfiguration, and if it sees the jdbc jars on the classpath, will add/execute DataSourceAutoConfiguration. The code above turns off this behavior.

Todd
  • 30,472
  • 11
  • 81
  • 89
  • Thanks @Todd (+1) but I'm not following -- I don't have any classes annotated with `@EnableAutoConfiguration` in my whole project, nor do I have any `spring.datasource.*` properties defined in my config file... – hotmeatballsoup Sep 02 '18 at 15:43
0

If you are using @SpringBootApplication decorator you can exclude by using the DataSourceAutoConfiguration as done in the @EnableAutoConfiguration decorator as well. Documentation ref

@Configuration
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class MyApplication {
// ...
}
Dark Light
  • 1,210
  • 11
  • 19