0

The presence of a second datasource in a spring boot application is failing caching with the exception:

java.lang.IllegalArgumentException: Cannot find cache named 'entity-name' for CacheEvictOperation 

With one datasource it's working.

Both the datasource is auto-configured by spring boot.

  • Datasource one using mysql, declared as primary

  • Datasource two using mongodb

Is this a known case? Do I need to explicitly configure entity and transaction managers?

1 Answers1

1

Spring Boot does not support auto-configuring more than one datasources for general purposes so you may want to revisit your configuration (or the description).

Yes, you need to configure the entity manager and transaction managers explicitly when you need to use more than one datasource.

Hopefully, this sample shows you how to do it.

Stephane Nicoll
  • 31,977
  • 9
  • 97
  • 89