micronaut-sql icon indicating copy to clipboard operation
micronaut-sql copied to clipboard

Allow lazy loading of the data sources

Open ikovalyov opened this issue 3 years ago • 3 comments

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

ikovalyov avatar Mar 29 '21 12:03 ikovalyov

You should probably have a different profile where data-sources properties are only provided in the command line profile.

dstepanov avatar May 13 '21 16:05 dstepanov

@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

sdelamo avatar Jun 02 '21 05:06 sdelamo

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.

nhoughto avatar Nov 24 '21 04:11 nhoughto