I have a problem with a code I am developing in Clojure:
(ns problem2 (:require [cheshire.core :as json]
[clojure.spec.alpha :as s]
[invoice-spec]))
(defn json->map [file-name]
(-> file-name
slurp
json/parse-stream
:invoice))
(defn generate-invoice [file-name]
(let [invoice (json->map file-name)
customer {:name (:company_name (:customer invoice))
:email (:email (:customer invoice))}
items (map (fn [item]
{:price (:price item)
:quantity (:quantity item)
:sku (:sku item)
:taxes (map (fn [tax]
{:category (keyword (:tax_category tax))
:rate (:tax_rate tax)})
(:taxes item))})
(:items invoice))]
{:issue-date (java.util.Date. (:issue_date invoice))
:customer customer
:items items}))
(defn -main []
(let [invoice (generate-invoice "invoice.json")]
(if (s/valid? ::invoice-spec/invoice invoice)
(println "Invoice is valid")
(println "Invoice is not valid"))))
When I try to import external libraries here, and using deps.edn:
{:deps {org.clojure/data.json {:mvn/version "2.4.0"}
org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/spec.alpha {:mvn/version "0.2.194"}
cheshire {:mvn/version "5.10.0"}}
}
There is always the same error, just like this:
Execution error (FileNotFoundException) at problem2/eval138$loading (problem2.clj:1).
Could not locate cheshire/core__init.class, cheshire/core.clj or cheshire/core.cljc on classpath.
I don’t know what I am doing wrong, please help.
Pd. I need to develop the solution using deps.edn. Thanks
New contributor
Luis Carlos Castillo Martin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.