1

当我尝试通过命令创建战争文件时

lein with-profile prod immutant war

我收到一条错误消息:

使用配置文件执行任务“immutant”时遇到错误:“prod”Uberjar 中止,因为 jar 失败:没有方法实现::协议文件:#'clojure.java.io/Coercions 为类找到:java.lang 。特点

我的项目文件如下

(defproject company/project-name "0.0.2-SNAPSHOT"
  :description "project description"
  :url "http://www.comapny-url.com"
  :license {:name "company name license"
            :url "http://www.company-url.com"}
  :min-lein-version "2.4.3"
  :java-opts ["-Xmx5g" "-server" "-XX:-OmitStackTraceInFastThrow"]
  :exclusions [org.clojure/clojure]
  :dependencies [[company/lib-name1 "1.2.9" :exclusions [com.taoensso/encore]]
                 [company/lib-name2 "1.1.1"]
                 [org.clojure/clojure "1.6.0"]
                 [org.clojure/data.zip "0.1.1"]
                 [org.clojure/tools.nrepl "0.2.10"]
                 [com.palletops/leaven "0.3.1"]
                 [com.github.kyleburton/clj-xpath "1.4.5"]
                 [metrics-clojure "2.5.1"]]
  :java-source-paths ["java/src"]
  :javac-options ["-target" "1.7" 
                  "-source" "1.7" "-Xlint:-options" 
                  "-cp" "resources/jars/jms-lib.jar:resources/jars/clojure-1.6.0.jar:resources/jars/log4j-1.2.17.jar"
                  "-d" "resources/classes"]
  :profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace "0.2.11"]]
                   :plugins [[lein-package "2.1.1"]
                             [lein-marginalia "0.7.1"]]}
             :prod {:source-paths "prod"
                    :main prod}}
  :prep-tasks ["javac" "compile"]
  :resource-paths ["resources/classes"]
  :plugins [[lein-package "2.1.1"]
            [lein-immutant "2.0.1"]]
  :immutant {:war {:resource-paths ["war-resources"]}
             :nrepl {:port 8183
                     :host "0.0.0.0"
                     :interface "0.0.0.0"
                     :start? true}}
  :hooks [leiningen.package.hooks.deploy leiningen.package.hooks.install]
  :package {:skipjar true
            :autobuild true
            :reuse false
            :artifacts [{:build "with-profile prod immutant war --name=%p%v%t" :extension "war"}]}
  :uberjar-exclusions [#"(?i)^META-INF/[^/]*\.SF$"] ;; Eliminate the signing code from the uberjar
  :repositories ^:replace [["nexus" {:url "comapny.respository.net"}]])

产品配置文件的布局如下

(ns prod
      (:require  
        [company.lib-name3
         [debug :as debug]
         [system :refer (go)]])
  (:gen-class))

(defn -main
  "Initialize and start the app as a war"
  []
  (go))

如果我使用如下布局的开发配置文件,我可以构建一个 uberjar:

(ns user
    "Tools for interactive development with the REPL. This file should
    not be included in a production build of the application."
    (:require  [clojure.java.io :as io]
        [clojure.java.javadoc :refer  (javadoc)]
        [clojure.pprint :refer  (pprint)]
        [clojure.reflect :refer  (reflect)]
        [clojure.repl :refer  (apropos dir doc find-doc pst source)]
        [clojure.set :as set]
        [clojure.string :as str]
        [clojure.test :as test]
        [clojure.tools.namespace.repl :refer  (refresh refresh-all)]
        [company.lib-name3
         [debug :as debug]
         [system :refer (go)]]))

(defn -main
  []
  (go))
4

1 回答 1

1

我的 project.clj 文件的 prod 配置文件中的源路径需要在一个向量中,而不仅仅是一个字符串。

:profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace "0.2.11"]]
                   :plugins [[lein-package "2.1.1"]
                             [lein-marginalia "0.7.1"]]}
             :prod {:source-paths ["prod"]
                    :main prod}}

代替

:profiles {:dev {:source-paths ["dev"]
                   :dependencies [[org.clojure/tools.namespace "0.2.11"]]
                   :plugins [[lein-package "2.1.1"]
                             [lein-marginalia "0.7.1"]]}
             :prod {:source-paths "prod"
                    :main prod}}
于 2015-10-26T13:37:45.763 回答