【发布时间】:2017-09-19 01:18:53
【问题描述】:
我正在尝试使用 Distillery 创建我的 Phoenix 应用程序的版本,并且我已经覆盖了 DateTime 和 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
【问题讨论】:
标签: elixir elixir-poison