我是凤凰城和长生不老药的新手。我正在创建一个作为后端API服务器的凤凰web服务器。我遵循凤凰城框架网站上的步骤。
软件版本:
Erlang/OTP 21 erts-10.2.4 64位ds:4:4:10 hipe 灵丹妙药1.8.1 (与Erlang/OTP 20汇编) 菲尼克斯v1.4.0-dev
和德普
{:phoenix, github: "phoenixframework/phoenix", override: true},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.2"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:cowboy, "~> 1.0"}当我试图运行mix phx.server时,我会收到以下错误:
[info] Application hello exited: Hello.Application.start(:normal, []) returned an error: shutdown: failed to start child: HelloWeb.Endpoint
** (EXIT) an exception was raised:
** (UndefinedFunctionError) function Plug.Cowboy.child_spec/1 is undefined (module Plug.Cowboy is not available)
Plug.Cowboy.child_spec([scheme: :http, plug: {HelloWeb.Endpoint, []}, options: [dispatch: [_: [{"/phoenix/live_reload/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {HelloWeb.Endpoint, Phoenix.LiveReloader.Socket, [path: "/websocket", serializer: [{Phoenix.Socket.V1.JSONSerializer, "~> 1.0.0"}, {Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}], timeout: 60000, transport_log: false, compress: false]}}}, {"/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {HelloWeb.Endpoint, HelloWeb.UserSocket, [path: "/websocket", serializer: [{Phoenix.Socket.V1.JSONSerializer, "~> 1.0.0"}, {Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}], timeout: 60000, transport_log: false, compress: false]}}}, {:_, Plug.Adapters.Cowboy.Handler, {HelloWeb.Endpoint, []}}]], port: 4000, otp_app: :hello]])
(phoenix) lib/phoenix/endpoint/cowboy_adapter.ex:96: Phoenix.Endpoint.CowboyAdapter.child_spec/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:108: anonymous fn/6 in Phoenix.Endpoint.Supervisor.server_children/4
(elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:99: Phoenix.Endpoint.Supervisor.server_children/4
(phoenix) lib/phoenix/endpoint/supervisor.ex:59: Phoenix.Endpoint.Supervisor.init/1
(stdlib) supervisor.erl:295: :supervisor.init/1
(stdlib) gen_server.erl:374: :gen_server.init_it/2
(stdlib) gen_server.erl:342: :gen_server.init_it/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3我试着将牛仔的版本改为2.6.3 (这似乎是最新的版本),但仍然会出现同样的错误。
请帮我解决这个问题。
沙伊拉-Thanks湾
发布于 2021-08-27 07:54:07
我只是在更新一个旧项目时遇到了同样的问题。显然,克里斯麦考德把凤凰更新指南放在他的基本帐户。你可以从这里找到一切:https://gist.github.com/chrismccord
因此,如果要从1.3更新到1.4,就必须将牛仔依赖项替换为plug_cowboy。

详细说明可在以下网址获得:https://gist.github.com/chrismccord/bb1f8b136f5a9e4abc0bfc07b832257e
https://stackoverflow.com/questions/56112319
复制相似问题