2016-05-01 35 views
2

我想在Eclipse中設置生產和開發配置文件,以便在Heroku上部署我的compojure/ring應用程序。但是,逆時針插件不會加載配置文件中的環境變量。我在環境選項卡中添加了變量並重新啓動了REPL,但變量仍然不可用。這就是我添加它們的方式:environment variables逆時針設置環境變量

我自己也嘗試添加變量profiles.clj但無濟於事:

`:profiles 
    {:production 
     {:ring 
     {:open-browser? false, 
     :stacktraces? false, 
     :auto-reload? false} 
     :env {:port 3000 
      :db-url "//localhost/login" 
      :db-user "test" 
      :db-pass "test" 
      :galleries-path "test"}} 
     :dev 
     {:dependencies [[ring-mock "0.1.5"] 
         [ring/ring-devel "1.2.0"]] 
     :env {:port 3000 
       :db-url "//localhost/gallery" 
       :db-user "test" 
       :db-pass "testProd" 
       :galleries-path "galleries"}}}` 

回答

0

當您採用環保,無毒,它會自動強制轉換"DB_URL"到更地道:db-url。看一下environ的強制代碼,看起來好像沒什麼關係,但我會嘗試大寫,並強調你在Environment選項卡中設置的所有環境變量。

+0

作出修改建議後,我收到以下錯誤: 'db-spec {:password nil, :subprotocol "postgresql", :user nil, :subname nil} is missing a required parameter' 這裏是我的DB-規格: '(def db {:subprotocol "postgresql" :subname (env :db-url) :user (env :db-user) :password (env :db-pass)})' 我只是不知道所需的參數是什麼。 –

+0

可能是零值是缺失的? –

+0

你是對的。然而,問題不在於零值缺失,而在於它們沒有得到適當的評估,這又回到了關於環境如何強制環境變量的觀點。建議更改後,我的DB-規格如下所示: '(DEF DB {:子協議 「的PostgreSQL」 :子名(ENV:DB_URL) :用戶(ENV:DB_USER) :密碼(ENV:DB_PASS)} )' 當運行'db'時,得到以下結果: '=>分貝 {:子協議 「的PostgreSQL」, :子名稱零, :用戶零, :密碼零}' –