- Clojure for Java Developers
- Eduardo Díaz
- 288字
- 2021-07-16 09:49:47
Creating a new project
Leiningen can help us create a new project using templates, there is a wide variety of templates available and you can build and distribute your own in Maven.
Some of the most common types of templates are:
- Creating a
jar
library (the default template) - Creating a command-line app
- Creating a Clojure web app
Let's create a new Clojure command-line app and run it:
lein new app getting-started cd getting-started lein run # Hello, world!
Project structure
Leiningen is similar to other Java development tools; it uses a similar convention and allows for heavy customizations in the project.clj
file.
If you are familiar with Maven or Gradle, you can think of it as pom.xml
or build.gradle
respectively.
The following screenshot is the project structure:

As you can see in the preceding screenshot, there are four main folders:
resources
: It holds everything that should be in the class path, such as files, images, configuration files, properties files, and other resources needed at runtime.src
: Your Clojure source files; they are ordered in a very similar fashion to theclasspath
.dev-resources
: Everything that should be in theclasspath
in development (when you are running Leiningen). You can override your "production" files here and add files that are needed for tests to run.test
: Your tests; this code doesn't get packaged but it is run every time you execute the Leiningen test.
Creating a standalone app
Once your project is created, you can build and run a Java standalone command-line app quite easily, let's try it now:
lein uberjar java -jar target/uberjar/getting-started-0.1.0-SNAPSHOT-standalone.jar # Hello, World!
As you can see, it is quite easy to create a standalone app and it is very similar to using Maven or Gradle.
- JavaScript從入門(mén)到精通(微視頻精編版)
- Learning Cython Programming
- JavaScript+DHTML語(yǔ)法與范例詳解詞典
- MATLAB應(yīng)用與實(shí)驗(yàn)教程
- Mastering Unity Shaders and Effects
- 差分進(jìn)化算法及其高維多目標(biāo)優(yōu)化應(yīng)用
- Drupal 8 Configuration Management
- 零基礎(chǔ)學(xué)Python網(wǎng)絡(luò)爬蟲(chóng)案例實(shí)戰(zhàn)全流程詳解(高級(jí)進(jìn)階篇)
- Rust Essentials(Second Edition)
- 精通Linux(第2版)
- Scala程序員面試算法寶典
- 學(xué)習(xí)正則表達(dá)式
- Go語(yǔ)言開(kāi)發(fā)實(shí)戰(zhàn)(慕課版)
- 自學(xué)Python:編程基礎(chǔ)、科學(xué)計(jì)算及數(shù)據(jù)分析(第2版)
- 從Excel到Python數(shù)據(jù)分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應(yīng)用