I use Leiningen to manage my CLJ project. When I want to wrap a Java library, I found that I have to introduce it to my project firstly.
我使用Leiningen来管理我的CLJ项目。当我想要包装一个Java库时,我发现我必须首先将它介绍给我的项目。
How can I use a library in a Maven repo in my project?
如何在项目中使用Maven仓库中的库?
2 个解决方案
#1
36
You just need to add it to your project.clj dependencies as any other clojure lib. The small difference is that java libraries have a groupId apart from the artifactId. For example to import the active-mq library you will need to add to your :dependencies
您只需将其作为任何其他clojure lib添加到project.clj依赖项中。不同的是,java库除了artifactId之外还有一个groupId。例如,要导入active-mq库,您需要添加到:dependencies
[org.apache.activemq/activemq-core "5.5.0"]
The first bit is the groupId, the second is the artifactId.
第一位是groupId,第二位是artifactId。
Also, if the library is not in the central maven repository, you will need to add the repository configuration to your project. For example, to add the sonatype snapshot repository:
此外,如果库不在*maven存储库中,则需要将存储库配置添加到项目中。例如,要添加sonatype快照存储库:
:repositories {"sonartype snapshots" "https://oss.sonatype.org/content/repositories/snapshots"}
#2
1
get the library's groupId, artifactId, and version, add into lein's dependencies, as same clojure project, The small difference is: download from http://repo1.maven.org/maven2.
获取库的groupId,artifactId和版本,添加到lein的依赖项中,作为相同的clojure项目,小的区别是:从http://repo1.maven.org/maven2下载。
#1
36
You just need to add it to your project.clj dependencies as any other clojure lib. The small difference is that java libraries have a groupId apart from the artifactId. For example to import the active-mq library you will need to add to your :dependencies
您只需将其作为任何其他clojure lib添加到project.clj依赖项中。不同的是,java库除了artifactId之外还有一个groupId。例如,要导入active-mq库,您需要添加到:dependencies
[org.apache.activemq/activemq-core "5.5.0"]
The first bit is the groupId, the second is the artifactId.
第一位是groupId,第二位是artifactId。
Also, if the library is not in the central maven repository, you will need to add the repository configuration to your project. For example, to add the sonatype snapshot repository:
此外,如果库不在*maven存储库中,则需要将存储库配置添加到项目中。例如,要添加sonatype快照存储库:
:repositories {"sonartype snapshots" "https://oss.sonatype.org/content/repositories/snapshots"}
#2
1
get the library's groupId, artifactId, and version, add into lein's dependencies, as same clojure project, The small difference is: download from http://repo1.maven.org/maven2.
获取库的groupId,artifactId和版本,添加到lein的依赖项中,作为相同的clojure项目,小的区别是:从http://repo1.maven.org/maven2下载。