I'm afraid that didn't quite work (no change in behavior).
Did I correctly understand you to mean this?
@Inject
@Config(value = { "trellis.configFile", "TRELLIS_CONFIG_FILE" })
private Optional<File> configFile;
I've also tried it with required=false:
@Inject
@Config(value = { "trellis.configFile", "TRELLIS_CONFIG_FILE" }, required =
false)
private Optional<File> configFile;
with the same behavior...
ajs6f
> On Oct 18, 2018, at 6:02 PM, Anatole Tresch <[email protected]> wrote:
>
> the problem is that CDI dies not support optional values in this way, this
> works in a non cdi env e.g. Spring, osgi.... What should work is injecting
> an Optional<File>.
>
> ajs6f <[email protected]> schrieb am Do., 18. Okt. 2018, 17:51:
>
>> Hi, Tamaya folks!
>>
>> I just tried using the required=false attribute of
>> o.a.t.inject.api.Config, on a field, with a CDI project, a la:
>>
>> @Inject
>> @Config(value = { "trellis.configFile", "TRELLIS_CONFIG_FILE" }, required
>> = false)
>> private File configFile;
>>
>> Unfortunately, it didn't seem to make the value truly optional. I got the
>> expectable:
>>
>> org.apache.tamaya.ConfigException: Cannot resolve any of the possible
>> configuration keys: [trellis.configFile, TRELLIS_CONFIG_FILE]. Please
>> provide one of the given keys with a value in your configuration sources.
>>
>> Is required=false supported in that position, or am I misunderstanding its
>> semantics?
>>
>> Thanks!
>>
>> ajs6f
>>
>>