- 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.
- Java Web開發(fā)學(xué)習(xí)手冊
- Python快樂編程:人工智能深度學(xué)習(xí)基礎(chǔ)
- 前端跨界開發(fā)指南:JavaScript工具庫原理解析與實(shí)戰(zhàn)
- 軟件測試工程師面試秘籍
- GameMaker Programming By Example
- 運(yùn)用后端技術(shù)處理業(yè)務(wù)邏輯(藍(lán)橋杯軟件大賽培訓(xùn)教材-Java方向)
- Web前端應(yīng)用開發(fā)技術(shù)
- HoloLens與混合現(xiàn)實(shí)開發(fā)
- Hacking Android
- Photoshop智能手機(jī)APP界面設(shè)計
- Java EE 8 and Angular
- Drupal 8 Development:Beginner's Guide(Second Edition)
- Software-Defined Networking with OpenFlow(Second Edition)
- Mastering ASP.NET Web API
- 打造流暢的Android App