DX-First Thinking: Why I Added @EnableTenantIsolation
to My Spring Boot Starter
Day 3 of building multi-tenant-springboot-starter
was less about code, more about mindset.
I wanted developers to switch between DATABASE
, SCHEMA
, and SHARED
isolation strategies for tenants. The default Spring Boot way would be
application.yml:
tenant:
strategy: DATABASE
That works, but I asked myself:
βWhat would it look like if Spring had built this?β
So I created:
@EnableTenantIsolation(strategy = TenantIsolationStrategy.SCHEMA)
π‘ This annotation uses ImportBeanDefinitionRegistrar and EnvironmentAware to inject the tenant.strategy key into the Spring Environment β before anything binds.
What I learned:
Boot auto-config works great, but it doesn't understand your custom annotations β unless you bridge them using @import(...)
The BEAN_CONTAINER trick in JPA is mandatory when manually wiring multiple EntityManagerFactoryBeans β without it, entity scanning breaks
Key Takeaway:
Framework-level DX is about thinking like Spring, not just using it.
Tomorrow: schema-per-tenant Hibernate integration.
Repo: github.com/rahul-s-bhatt/multi-tenant-springboot-starter
Follow for more build-in-public logs β¨
Top comments (0)