我正在尝试使用 Distillery 创建我的 Phoenix 应用程序的版本,并且我已经覆盖了 Poison EncodersDateTime
以NaiveDateTime
匹配 API 要求。
当我运行时mix release
,我的应用程序会编译,但在 .boot 生成期间出现错误。
这是堆栈跟踪:
$> mix release
warning: variable "aliases" does not exist and is being expanded to "aliases()", please use parentheses to remove the ambiguity or change the variable name
mix.exs:12
warning: variable "deps" does not exist and is being expanded to "deps()", please use parentheses to remove the ambiguity or change the variable name
mix.exs:13
==> Assembling release..
==> Building release helios:1.0.0 using environment dev
==> One or more direct or transitive dependencies are missing from
:applications or :included_applications, they will not be included
in the release:
:ex_admin
:floki
:geo
:guardian
:json_web_token
:mogrify
:phoenix_pubsub
:scrivener_ecto
:timex
:timex_ecto
This can cause your application to fail at runtime. If you are sure
that this is not an issue, you may ignore this warning.
==> Release failed, during .boot generation:
Duplicated modules:
'Elixir.Poison.Encoder.NaiveDateTime' specified in poison and helios
'Elixir.Poison.Encoder.Ecto.DateTime' specified in ecto and helios
有没有办法在不遇到这个问题的情况下覆盖毒药编码器?
编辑:这是我拥有的编码器:
defimpl Poison.Encoder, for: Ecto.DateTime do
def encode(datetime, options) do
dt = datetime |> Ecto.DateTime.to_erl
|> Timex.Timezone.convert("UTC")
|> Timex.format("{ISO:Extended}")
|> elem(1)
<<?", dt::binary, ?">>
end
end
defimpl Poison.Encoder, for: NaiveDateTime do
def encode(datetime, options) do
dt = datetime
|> Timex.Timezone.convert("UTC")
|> Timex.format("{ISO:Extended}")
|> elem(1)
<<?", dt::binary, ?">>
end
end