Cannot for the life of me get Coldbox to recognize my datasource settings. Here’s what I have in my config/Coldbox.cfc file:
// custom settings settings = { mainDataSource = { type = “SQL”, name = "myDataSourceNameAsDefinedInCFAdmin" } };
And here’s how I’m injecting in my DAO: property name=‘dsn’ inject=‘coldbox:settings:mainDataSource’;
I continually get the below error: Messages: The DSL provided was not valid: {JAVACAST={null},REF={null},SCOPE={variables},REQUIRED={true},VALUE={null},DSL={coldbox:settings:mainDataSource},TYPE={any},ARGNAME={},NAME={dsn}}
Yes, I was stung by this yesterday too… the docs say “settings”. I also was stung by having to use the @ModuleName when injecting datasources as well. While I was used to this DSL for a module’s models, etc. - datasources hadn’t needed this when they had their own setting… now they do.
Anyways - just offering that up for anybody else who may get stuck and not realize it.
Note, ColdBox no longer has any concept of a thing called a “datasource”. These are just normal settings just like any other setting. You name it what you want and you inject it with the generic rules for injecting settings.
It’s in the Upgrading to CB 5 section under “Datasources Configuration Dropped” section:
Re: @modulename and datasource key - yes, I’m aware of using these items. I was just pointing out that injecting datasources that were configured in ModuleConfig CFCs previously didn’t require the @modulename as they were added to the global datasources setting. I was updating an app with more than a dozen different datasources setup in so many modules and mistakenly thought I could do a global search and replace to change all of my property injections from “coldbox:datasource:mydsn” to “coldbox:setting:mydsn” (however this did not work because of the aforementioned @modulename requirement.)
The requirement was there before, but wasn’t necessary for datasources. I just thought others may run into the same issue of they were migrating from 4.x to 5.x so I pointed it out!
Thanks, I fixed the typo. If you want to contribute your module-specific datasource settings to the parent ColdBox settings struct, use the parentSettings struct. Then you should be able to inject it with the non-module syntax.