micronaut-sql
micronaut-sql copied to clipboard
Allow lazy loading of the data sources
We don't need to load datasources in our web app, or tests. We need it only if app is loaded from the command line. Unfortunately there is no way to do a lazy loading of the datasources as it is annotated with @Context
You should probably have a different profile where data-sources properties are only provided in the command line profile.
@ikovalyov
what you could do is to move the datasources
block to a configuration file such as application-cli.yml
.
Then it would not be loaded unless you run with environments such as cli
Would love this, causing a bit of pain atm with shared/inherited config, where datasource config is specified at a higher level and this triggers downstream components to try and construct the Datasource where i'd like them not to.
I believe the idiomatic micronaut way to do this is to support io.micronaut.core.util.Toggleable
and then configure the data source as enabled: false
at a higher level, and then enabled: true
at the lower level. Lots of other areas/configurations support this Toggleable but not Datasource.