Dependency is not added to clojure project

Asked

Viewed 34 times

0

I’m learning Clojure and created a simple spellchecker project. In this project, I would like to use the Stringutils class from Apache Commons, so I added the following lines of code to import it into my project.

; arquivo core.clj -- contém o método main
(ns spellchecker.core
  (:require [clojure.string :as str])
  (:import (org.apache.commons.langr StringUtils)))


; arquivo project.clj -- contém as dependências
(defproject spellchecker "0.1.0-SNAPSHOT"
  :description "simple spell checker"
  :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"]
                [org.apache.commons/commons-lang3 "3.3.2"]]
  :main ^:skip-aot spellchecker.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

However, when I execute the command lein run inside the directory of my project. I get the error: CompilerException java.lang.ClassNotFoundException: org.apache.commons.langr.StringUtils, compiling:(/home/leonardo/clojure-learning/spellchecker/src/spellchecker/core.clj:1:1) which basically says that the dependency has not been downloaded. How can I download dependencies before or when running the project?

1 answer

0

The problem is the incorrect name of the package in the file core.clj.

To resolve, replace

(:import (org.apache.commons.langr StringUtils)))

for

(:import (org.apache.commons.lang3 StringUtils)))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.