【发布时间】:2022-01-22 15:19:27
【问题描述】:
如何在Phoenix 框架中为mix ecto.create 命令指定自定义服务器端口?
我使用mix phx.new hello 命令创建了一个入门项目。
我在hello\config\dev.exs路径中配置数据库如下,
config :hello, Hello.Repo,
username: "postgres",
password: "postgres",
hostname: "localhost",
database: "hello_dev",
show_sensitive_data_on_connection_error: true,
pool_size: 10
但是,当我尝试使用 mix ecto.create 命令配置 Postgres 数据库 时,出现以下错误。
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
我使用 5433 作为 Postgres 端口(注意:它适用于我的 spring java 项目),因为默认端口 5432 在我的本地不可用。
所以在hello\deps\ecto_sql\lib\ecto\adapters\postgres\connection.ex 路径中
我在路径中定义了默认端口如下,
@default_port 5433
但如果我再次运行该命令,它仍会尝试连接到 5432。
如何获得连接到 5433 而不是 5432 的命令?
【问题讨论】:
-
一些忠告:不要碰
/deps文件夹中的代码! 这些依赖项由mix根据您在mix.exs中的项目设置进行管理.如果您想自定义库:克隆库,进行一些调整并参考您的deps中的 github 存储库或本地路径,如 here 所述。 -
非常感谢zwippie的建议。
标签: postgresql elixir phoenix-framework