Clojure - 将文件添加到类路径

Clojure - add file to the classpath

如何将资源(最好以编程方式)添加到我的程序的类路径中?

我正在使用 compojure.route.resources,如下所示:

A route for serving resources on the classpath. Accepts the following keys: :root - the root prefix path of the resources, defaults to 'public' :mime-types - an optional map of file extensions to mime types

(defroutes routes
  (resources "/js" {:root "js"})
  (resources "/css" {:root "css"}))

现在我想添加要提供的文件,但我不知道在哪里生成它们。

注意: 以防万一,我使用的是 boot and the example is taken from this template

在常规的基于引导的项目中,您可以在根目录下有一个资源文件夹:

-rw-r--r--@  1 niko  staff   173 Dec 18 10:19 boot.properties
-rw-r--r--@  1 niko  staff  2796 Dec 30 09:55 build.boot
drwxr-xr-x@ 17 niko  staff   578 Dec 30 10:49 resources
drwxr-xr-x@  4 niko  staff   136 Nov 16 09:52 src
drwxr-xr-x@ 17 niko  staff   578 Jan 14 11:50 target

在该文件夹中,您可以创建 css 和 js 文件夹并在其中包含您的文件:

drwxr-xr-x@ 5 niko  staff  170 Dec 14 15:33 resources/css/
drwxr-xr-x@ 4 niko  staff  136 Nov 30 18:01 resources/js/