[ https://issues.apache.org/jira/browse/TAMAYA-358?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16688381#comment-16688381 ]
ASF GitHub Bot commented on TAMAYA-358: --------------------------------------- Github user peculater commented on the issue: https://github.com/apache/incubator-tamaya-extensions/pull/12 For that use I'd go with ``` @Inject @Config private Optional<String> myConfigVal; ``` The default config name is the name of the variable, and "required=(true|false)" doesn't change the result if you're using Optional<T>. I'm super interested in how well this works for you. :-) > No way to inject an optional config value via CDI > ------------------------------------------------- > > Key: TAMAYA-358 > URL: https://issues.apache.org/jira/browse/TAMAYA-358 > Project: Tamaya > Issue Type: Bug > Affects Versions: 0.3-incubating > Reporter: A. Soroka > Priority: Minor > Labels: cdi, injection, optional > > It's not possible to use {{@Config}} to inject an optional value in a CDI > project. None of the following work: > {code:java} > @Inject > @Config(value = { "trellis.configFile", "TRELLIS_CONFIG_FILE" }, > required=false) > private File configFile; > {code} > {code:java} > @Inject > @Config(value = { "trellis.configFile", "TRELLIS_CONFIG_FILE" }, > required=false) > private Optional<File> configFile; > {code} > {code:java} > @Inject > @Config(value = { "trellis.configFile", "TRELLIS_CONFIG_FILE" }) > private Optional<File> configFile; > {code} > All throw a > {noformat} > 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. > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)