我是 Elixir 和 Phoenix 的新手,所以这个问题可能相当简单。我的 Phoenix 应用程序是一个 API 客户端,我正在尝试创建一个结构来对我将从 REST 端点接收的数据进行建模。我基本上按照Poison GitHub 页面上的小例子来创建我的模块:
defmodule ElixirServer.CurrentlyReprModule do
@derive [Poison.Encoder]
defstruct [:id, :time, :summary, :icon, :nearestStormDistance,
:nearestStormBearing, :precipIntensity, :precipProbability, :temperature,
:apparentTemperature, :dewPoint, :humidity, :pressure, :windSpeed, :windGust,
:windBearing, :cloudCover, :uvIndex, :visibility, :ozone]
end
该模块位于lib/elixir_server/
(这甚至是此类文件的最佳位置吗?)。
我的问题是当我尝试编译文件时出现此错误:
(CompileError) lib/elixir_server/currently_repr_module.ex:2: module Poison.Encoder is not loaded and could not be found
当我尝试运行时,iex -S mix
我收到类似的错误:
(UndefinedFunctionError) function Poison.Encoder.__using__/1 is undefined or private
Poison 包含在 mix.exs 的依赖项中。如何解决此错误?