我是一個Dropwizard新手,並且正在使用現有的Dropwizard服務,我嘗試創建YML值,這些值根據我的服務部署到的環境(即Dev,QA ,Prod)。我試着用谷歌搜索我的錯誤信息,但是對於這個特定的錯誤並沒有發現很多,所以我想我會爲此發佈一個新問題。Dropwizard Enviornment變量替換類型檢查錯誤
當我運行我的腳本,啓動服務,我得到以下錯誤:
my-host:my-service jthoms$ ./start.sh 3.0.0
Starting my-service...
src/main/resources/configuration.yml has an error:
* Incorrect type of value at: downstream_service.loggingEnabled; is of type: String, expected: boolean
請注意,我已經創建了MyServiceConfiguration
類延伸Dropwizard的主要Configuration
類,並委託給具有DownstreamServiceConfiguration
類loggingEnabled
屬性的布爾型字段。我按照Dropwizard Core doc這樣做了。
我start.sh
腳本如下:
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Please pass jar version! Usage: ./start.sh <jar_version>"
exit 1
fi
echo "Starting my-service with version '$1'"
java $DEBUG_ARGS -Xmx128m -jar target/my-service-$1.jar server src/main/resources/configuration.yml
我configuration.yml
如下:
server:
...
downstream_service:
loggingEnabled: ${DW_DOWNSTREAM_SERVICE_LOGGING_ENABLED}
...
logging:
...
我不明白是什麼導致了這種類型的安全錯誤。如何將我的環境變量作爲非字符串類型導入Dropwizard?