试剂ClojureScript

试剂ClojureScript,clojure,macros,clojurescript,reagent,Clojure,Macros,Clojurescript,Reagent,我正在处理一个试剂项目,似乎无法使用macros.clj文件。不管我把它放在哪里,它总是给我同样的信息:“在类路径上找不到macros/core\uuu init.class或macros/core.clj。我应该把macros.clj文件放在哪里,或者我遗漏了什么? 结构如下: test-proj/ env/ dev/ clj/ test-proj/ middleware.clj

我正在处理一个试剂项目,似乎无法使用macros.clj文件。不管我把它放在哪里,它总是给我同样的信息:“在类路径上找不到macros/core\uuu init.class或macros/core.clj。我应该把macros.clj文件放在哪里,或者我遗漏了什么? 结构如下:

test-proj/
  env/
    dev/
        clj/
            test-proj/
                middleware.clj
                repl.clj
        cljs/
            test-proj/
                dev.cljs
    prod/
        clj/
            test-proj/
                middleware.clj
        cljs/
            test-proj/
                prod.cljs
  resources/
      public/
         css/
             site.css
  src/
      clj/
          test-proj/
              handler.clj
              server.clj
      cljc/
          test-proj/
              util.cljc
      cljs/
          test-proj/
              bmi.cljs
              core.cljs
              home.cljs
              macros.clj
              simple-examples.cljs
              timer.cljs
              todo.cljs
  target/
      classes/
          META-INF/
              maven/
                  test-proj/
                      test/proj/
                          pom.properties
      cljsbuild/
          public/
              js/
                  out/
                      ...
                  app.js
      stale/
          leiningen.core.classpath.extract-native-dependencies
          leiningen.figwheel.clean-on-dependency-change
  figwheel_server.log
  LICENSE
  Procfile
  project.clj
  README.md
  system.properties
(ns macros.core)
(defproject test-proj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [ring-server "0.4.0"]
                 [reagent "0.6.0"]
                 [reagent-utils "0.2.0"]
                 [ring "1.5.0"]
                 [ring/ring-defaults "0.2.1"]
                 [compojure "1.5.1"]
                 [hiccup "1.0.5"]
                 [yogthos/config "0.8"]
                 [org.clojure/clojurescript "1.9.473"
                  :scope "provided"]
                 [secretary "1.2.3"]
                 [venantius/accountant "0.1.7"
                  :exclusions [org.clojure/tools.reader]]]

  :plugins [[lein-environ "1.0.2"]
            [lein-cljsbuild "1.1.1"]
            [lein-ring "0.11.0"]
            [lein-asset-minifier "0.2.7"
             :exclusions [org.clojure/clojure]]]

  :ring {:handler test-proj.handler/app
         :uberwar-name "test-proj.war"}

  :min-lein-version "2.5.0"

  :uberjar-name "test-proj.jar"

  :main test-proj.server

  :clean-targets ^{:protect false}
  [:target-path
   [:cljsbuild :builds :app :compiler :output-dir]
   [:cljsbuild :builds :app :compiler :output-to]]

  :source-paths ["src/clj" "src/cljc"]
  :resource-paths ["resources" "target/cljsbuild"]

  :minify-assets
  {:assets
   {"resources/public/css/site.min.css" "resources/public/css/site.css"}}

  :cljsbuild
  {:builds {:min
            {:source-paths ["src/cljs" "src/cljc" "env/prod/cljs"]
             :compiler
             {:output-to "target/cljsbuild/public/js/app.js"
              :output-dir "target/uberjar"
              :optimizations :advanced
              :pretty-print  false}}
            :app
            {:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
             :compiler
             {:main "test-proj.dev"
              :asset-path "/js/out"
              :output-to "target/cljsbuild/public/js/app.js"
              :output-dir "target/cljsbuild/public/js/out"
              :source-map true
              :optimizations :none
              :pretty-print  true}}



            }
   }


  :figwheel
  {:http-server-root "public"
   :server-port 3449
   :nrepl-port 7002
   :nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"
                      ]
   :css-dirs ["resources/public/css"]
   :ring-handler test-proj.handler/app}



  :profiles {:dev {:repl-options {:init-ns test-proj.repl
                                  :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}

                   :dependencies [[ring/ring-mock "0.3.0"]
                                  [ring/ring-devel "1.5.0"]
                                  [prone "1.1.4"]
                                  [figwheel-sidecar "0.5.8"]
                                  [org.clojure/tools.nrepl "0.2.12"]
                                  [com.cemerick/piggieback "0.2.2-SNAPSHOT"]
                                  [pjstadig/humane-test-output "0.8.1"]
                                  ]

                   :source-paths ["env/dev/clj"]
                   :plugins [[lein-figwheel "0.5.8"]
                             ]

                   :injections [(require 'pjstadig.humane-test-output)
                                (pjstadig.humane-test-output/activate!)]

                   :env {:dev true}}

             :uberjar {:hooks [minify-assets.plugin/hooks]
                       :source-paths ["env/prod/clj"]
                       :prep-tasks ["compile" ["cljsbuild" "once" "min"]]
                       :env {:production true}
                       :aot :all
                       :omit-source true}})
my core.cljs文件中的命名空间如下所示:

(ns test-proj.core
(:require [reagent.core :as reagent :refer [atom]]
          [reagent.session :as session]
          [secretary.core :as secretary :include-macros true]
          [accountant.core :as accountant]
          [home.core :as h]
          [simple-examples.core :as se]
          [bmi.core :as b]
          [timer.core :as t]
          [todo.core :as td])
(:require-macros [macros.core :as m]))
my macros.core的命名空间如下所示:

test-proj/
  env/
    dev/
        clj/
            test-proj/
                middleware.clj
                repl.clj
        cljs/
            test-proj/
                dev.cljs
    prod/
        clj/
            test-proj/
                middleware.clj
        cljs/
            test-proj/
                prod.cljs
  resources/
      public/
         css/
             site.css
  src/
      clj/
          test-proj/
              handler.clj
              server.clj
      cljc/
          test-proj/
              util.cljc
      cljs/
          test-proj/
              bmi.cljs
              core.cljs
              home.cljs
              macros.clj
              simple-examples.cljs
              timer.cljs
              todo.cljs
  target/
      classes/
          META-INF/
              maven/
                  test-proj/
                      test/proj/
                          pom.properties
      cljsbuild/
          public/
              js/
                  out/
                      ...
                  app.js
      stale/
          leiningen.core.classpath.extract-native-dependencies
          leiningen.figwheel.clean-on-dependency-change
  figwheel_server.log
  LICENSE
  Procfile
  project.clj
  README.md
  system.properties
(ns macros.core)
(defproject test-proj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [ring-server "0.4.0"]
                 [reagent "0.6.0"]
                 [reagent-utils "0.2.0"]
                 [ring "1.5.0"]
                 [ring/ring-defaults "0.2.1"]
                 [compojure "1.5.1"]
                 [hiccup "1.0.5"]
                 [yogthos/config "0.8"]
                 [org.clojure/clojurescript "1.9.473"
                  :scope "provided"]
                 [secretary "1.2.3"]
                 [venantius/accountant "0.1.7"
                  :exclusions [org.clojure/tools.reader]]]

  :plugins [[lein-environ "1.0.2"]
            [lein-cljsbuild "1.1.1"]
            [lein-ring "0.11.0"]
            [lein-asset-minifier "0.2.7"
             :exclusions [org.clojure/clojure]]]

  :ring {:handler test-proj.handler/app
         :uberwar-name "test-proj.war"}

  :min-lein-version "2.5.0"

  :uberjar-name "test-proj.jar"

  :main test-proj.server

  :clean-targets ^{:protect false}
  [:target-path
   [:cljsbuild :builds :app :compiler :output-dir]
   [:cljsbuild :builds :app :compiler :output-to]]

  :source-paths ["src/clj" "src/cljc"]
  :resource-paths ["resources" "target/cljsbuild"]

  :minify-assets
  {:assets
   {"resources/public/css/site.min.css" "resources/public/css/site.css"}}

  :cljsbuild
  {:builds {:min
            {:source-paths ["src/cljs" "src/cljc" "env/prod/cljs"]
             :compiler
             {:output-to "target/cljsbuild/public/js/app.js"
              :output-dir "target/uberjar"
              :optimizations :advanced
              :pretty-print  false}}
            :app
            {:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
             :compiler
             {:main "test-proj.dev"
              :asset-path "/js/out"
              :output-to "target/cljsbuild/public/js/app.js"
              :output-dir "target/cljsbuild/public/js/out"
              :source-map true
              :optimizations :none
              :pretty-print  true}}



            }
   }


  :figwheel
  {:http-server-root "public"
   :server-port 3449
   :nrepl-port 7002
   :nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"
                      ]
   :css-dirs ["resources/public/css"]
   :ring-handler test-proj.handler/app}



  :profiles {:dev {:repl-options {:init-ns test-proj.repl
                                  :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}

                   :dependencies [[ring/ring-mock "0.3.0"]
                                  [ring/ring-devel "1.5.0"]
                                  [prone "1.1.4"]
                                  [figwheel-sidecar "0.5.8"]
                                  [org.clojure/tools.nrepl "0.2.12"]
                                  [com.cemerick/piggieback "0.2.2-SNAPSHOT"]
                                  [pjstadig/humane-test-output "0.8.1"]
                                  ]

                   :source-paths ["env/dev/clj"]
                   :plugins [[lein-figwheel "0.5.8"]
                             ]

                   :injections [(require 'pjstadig.humane-test-output)
                                (pjstadig.humane-test-output/activate!)]

                   :env {:dev true}}

             :uberjar {:hooks [minify-assets.plugin/hooks]
                       :source-paths ["env/prod/clj"]
                       :prep-tasks ["compile" ["cljsbuild" "once" "min"]]
                       :env {:production true}
                       :aot :all
                       :omit-source true}})
我的project.clj文件如下所示:

test-proj/
  env/
    dev/
        clj/
            test-proj/
                middleware.clj
                repl.clj
        cljs/
            test-proj/
                dev.cljs
    prod/
        clj/
            test-proj/
                middleware.clj
        cljs/
            test-proj/
                prod.cljs
  resources/
      public/
         css/
             site.css
  src/
      clj/
          test-proj/
              handler.clj
              server.clj
      cljc/
          test-proj/
              util.cljc
      cljs/
          test-proj/
              bmi.cljs
              core.cljs
              home.cljs
              macros.clj
              simple-examples.cljs
              timer.cljs
              todo.cljs
  target/
      classes/
          META-INF/
              maven/
                  test-proj/
                      test/proj/
                          pom.properties
      cljsbuild/
          public/
              js/
                  out/
                      ...
                  app.js
      stale/
          leiningen.core.classpath.extract-native-dependencies
          leiningen.figwheel.clean-on-dependency-change
  figwheel_server.log
  LICENSE
  Procfile
  project.clj
  README.md
  system.properties
(ns macros.core)
(defproject test-proj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [ring-server "0.4.0"]
                 [reagent "0.6.0"]
                 [reagent-utils "0.2.0"]
                 [ring "1.5.0"]
                 [ring/ring-defaults "0.2.1"]
                 [compojure "1.5.1"]
                 [hiccup "1.0.5"]
                 [yogthos/config "0.8"]
                 [org.clojure/clojurescript "1.9.473"
                  :scope "provided"]
                 [secretary "1.2.3"]
                 [venantius/accountant "0.1.7"
                  :exclusions [org.clojure/tools.reader]]]

  :plugins [[lein-environ "1.0.2"]
            [lein-cljsbuild "1.1.1"]
            [lein-ring "0.11.0"]
            [lein-asset-minifier "0.2.7"
             :exclusions [org.clojure/clojure]]]

  :ring {:handler test-proj.handler/app
         :uberwar-name "test-proj.war"}

  :min-lein-version "2.5.0"

  :uberjar-name "test-proj.jar"

  :main test-proj.server

  :clean-targets ^{:protect false}
  [:target-path
   [:cljsbuild :builds :app :compiler :output-dir]
   [:cljsbuild :builds :app :compiler :output-to]]

  :source-paths ["src/clj" "src/cljc"]
  :resource-paths ["resources" "target/cljsbuild"]

  :minify-assets
  {:assets
   {"resources/public/css/site.min.css" "resources/public/css/site.css"}}

  :cljsbuild
  {:builds {:min
            {:source-paths ["src/cljs" "src/cljc" "env/prod/cljs"]
             :compiler
             {:output-to "target/cljsbuild/public/js/app.js"
              :output-dir "target/uberjar"
              :optimizations :advanced
              :pretty-print  false}}
            :app
            {:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
             :compiler
             {:main "test-proj.dev"
              :asset-path "/js/out"
              :output-to "target/cljsbuild/public/js/app.js"
              :output-dir "target/cljsbuild/public/js/out"
              :source-map true
              :optimizations :none
              :pretty-print  true}}



            }
   }


  :figwheel
  {:http-server-root "public"
   :server-port 3449
   :nrepl-port 7002
   :nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"
                      ]
   :css-dirs ["resources/public/css"]
   :ring-handler test-proj.handler/app}



  :profiles {:dev {:repl-options {:init-ns test-proj.repl
                                  :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}

                   :dependencies [[ring/ring-mock "0.3.0"]
                                  [ring/ring-devel "1.5.0"]
                                  [prone "1.1.4"]
                                  [figwheel-sidecar "0.5.8"]
                                  [org.clojure/tools.nrepl "0.2.12"]
                                  [com.cemerick/piggieback "0.2.2-SNAPSHOT"]
                                  [pjstadig/humane-test-output "0.8.1"]
                                  ]

                   :source-paths ["env/dev/clj"]
                   :plugins [[lein-figwheel "0.5.8"]
                             ]

                   :injections [(require 'pjstadig.humane-test-output)
                                (pjstadig.humane-test-output/activate!)]

                   :env {:dev true}}

             :uberjar {:hooks [minify-assets.plugin/hooks]
                       :source-paths ["env/prod/clj"]
                       :prep-tasks ["compile" ["cljsbuild" "once" "min"]]
                       :env {:production true}
                       :aot :all
                       :omit-source true}})
错误:

----  Could not Analyze  src/cljs/test-proj/core.cljs  ----

  Could not locate macros/core__init.class or macros/core.clj on classpath.

----  Analysis Error : Please see src/cljs/test-proj/core.cljs  ----

要使用Clojurescript中的宏,请执行以下操作:

(ns my.namespace
  (:require-macros [my.macros :as my]))

以下是文档:

知道您为什么得到-1会很好。也许做这件事的人认为您到目前为止应该展示您的尝试-您的文件在哪里,您如何使用它们(代码)。