【问题标题】:Clojure - Ring uberjar specify portClojure - 环 uberjar 指定端口
【发布时间】:2015-11-29 06:52:33
【问题描述】:

如何生成一个独立的环uberjar 来监听给定的端口?

在开发时,我使用以下 leiningen/ring 命令启动我的应用程序,我可以在其中指定端口:

lein with-profile dev ring server-headless 9696

现在我想部署它,所以我跑了:

lein with-profile prod ring uberjar 9696

但我得到了一个错误:

Error encountered performing task 'ring' with profile(s): 'prod'
clojure.lang.ArityException: Wrong number of args (2) passed to: uberjar/uberjar

所以我在我的project.clj 中添加了一个:port

:ring    {:handler img-cli.handler/handler
          :init    img-cli.handler/init
          :destroy img-cli.handler/destroy
          :port    9696}

lein with-profile prod ring uberjar
java -jar my-jar.jar

但后来我在日志中看到:Started server on port 3000

如何使用我想要的端口生成uberjar

注意:以防万一,我使用的是compojure

【问题讨论】:

  • 它对我有用,你是否在应用 project.clj 中的更改后编译了 jar?
  • @PauloBu 啊原来我不得不使用lein with-profile +prod ring uberjar 9696(注意+

标签: clojure leiningen compojure ring


【解决方案1】:

事实证明,我对个人资料的使用存在问题。

仔细查看profile documentation 收益率:

要激活除默认配置之外的配置文件,请在其前面添加 +:

$ lein with-profile +server run

因此我不得不使用lein with-profile +prod ring uberjar 9696(注意+)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-21
    • 1970-01-01
    • 2015-11-20
    • 2021-01-22
    • 2018-04-25
    • 2011-01-04
    • 2013-06-16
    • 2023-02-08
    相关资源
    最近更新 更多