sorry if this isn’t the right place, but I’ve got some compojure routes like so
(defroutes routes
(GET "/" [] (index/index))
(route/resources "/")
(route/not-found "oh no"))i’ve got some static assets in resources/public
and they are 404'ing
is it laid out somewhere what directory to use?
Hmm, I thought the default was public on the classpath. Ah, how are you starting/running your app? Leiningen or Clojure CLI?
I can't remember whether lein puts resources on the classpath by default but deps.edn certainly doesn't -- you need to set :paths ["src" "resources"] in your deps.edn.
^ @cschep
ahhhh
clj -M -m schepball.main
with a pretty bare deps.edn
i was wondering how the tool knew where to look
maybe “resources” was a magic jvm directory or something
is src in deps.edn by default?
{:deps
{org.jsoup/jsoup {:mvn/version "1.13.1"}
dk.ative/docjure {:mvn/version "1.14.0"}
compojure/compojure {:mvn/version "1.6.2"}
ring/ring {:mvn/version "1.9.2"}}}this is my entire deps.edn
but i have code in src
that fixed it thank you!!
Yes, "src" is the default value for :paths. If you need additional directories, you need to specific (all of) them in your project deps.edn, so :paths ["src" "resources"] would need to be added.
You can see it reflected in the classpath here:
seanc@DESKTOP-30ICA76:~/clojure$ clojure -Spath
# just src on the path (plus Clojure's libs):
src:/home/seanc/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/home/seanc/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/home/seanc/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar
seanc@DESKTOP-30ICA76:~/clojure$ clojure -Sdeps '{:paths ["src" "resources"]}' -Spath
# now we have src and resources on the path:
src:resources:/home/seanc/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/home/seanc/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/home/seanc/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar