美文网首页
leiningen clojure web项目使用本地jar包

leiningen clojure web项目使用本地jar包

作者: 小马将过河 | 来源:发表于2020-02-06 12:36 被阅读0次

luminusweb模板创建的clojure web服务端项目如何使用本地的jar。

我的方案

将jar放在项目里的某个目录下,推荐resources下,然后在project.clj里加入引用即可。

:resource-paths ["resources/jars/sheet-clone-0.1.jar"]

使用的时候像跟调用其他第三方的java sdk一样使用

(:import (com.alibaba.excel EasyExcel #_ExcelWriter)
           [com.hczt.sheetclone.utils CloneExcelByPoi]
           [org.apache.poi.xssf.usermodel XSSFWorkbook])

其他方案:

参考Paul大神的文章using-local-jars-with-leiningen
贴一下主要内容。
Create a directory in the project.
mkdir maven_repository.
Add local jars to this repository.
For example, this command adds the jaad-0.8.3.jar file to the maven repository.

mvn install:install-file -Dfile=jaad-0.8.3.jar -DartifactId=jaad -Dversion=0.8.3 -DgroupId=jaad -Dpackaging=jar -DlocalRepositoryPath=maven_repository

Add the following to project.clj

:repositories {"local" ~(str (.toURI (java.io.File. "maven_repository")))}

Now a regular lein deps should work

lein deps
Downloading: jaad/jaad/0.8.3/jaad-0.8.3.pom from local
Transferring 0K from local
[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for jaad/jaad/0.8.3/jaad-0.8.3.pom - IGNORING

The warning can be ignored, since the jar will be checked into the project and not downloaded from the internet.

相关文章

网友评论

      本文标题:leiningen clojure web项目使用本地jar包

      本文链接:https://www.haomeiwen.com/subject/blwyxhtx.html