luminus web framework learning

Keywords: Programming SQL Maven brew xml

Chapter one your first program

Because I am a mac computer, I am temporarily based on my operation (clojure is not friendly to windows, jdk and maven data are too many, so I will not introduce the installation method here)

First, use brew install leiningen and brew install clojure to install lein and clojure

Lei is like the familiar clojure version of maven. After one execution, we need to set the domestic image

Please refer to this article settings lein domestic image

After installing lein, we can create the first program

lein new luminus guestbook +h2
cd guestbook

It's obvious here that the h2 database is used here. After all, it's still in the initial stage. If it's too complicated at the beginning, it's troublesome

OK, let's take a look at the structure of our new project

guestbook
├── Capstanfile #OSv deployment file
├── Dockerfile  #docker deployment file
├── Procfile    #Heroku deployment file
├── README.md   #Please read me.
├── env
│   ├── dev
│   │   ├── clj
│   │   │   ├── guestbook
│   │   │   │   ├── dev_middleware.clj  #Reserved development middleware, not compiled in production
│   │   │   │   └── env.clj     #Include development configuration defaults
│   │   │   └── user.cl         #Namespace in which users run code during repl development
│   │   └── resources
│   │       ├── config.edn      #Environment variables in development environment
│   │       └── logback.xml     #Log files in development environment
│   ├── prod
│   │   ├── clj
│   │   │   └── guestbook
│   │   │       └── env.clj     #production environment
│   │   └── resources
│   │       ├── config.edn
│   │       └── logback.xml
│   └── test
│       └── resources
│           └── config.edn
├── dev-config.edn    #Developed deployment files (do not enter code warehouse)
├── test-config.edn   #Test deployment files used
├── project.clj       #Configuration files used to manage and set project configuration and dependencies

├── resources
│   ├── docs
│   │   └── docs.md
│   ├── migrations
│   │   ├── 20160811175305-add-users-table.down.sql
│   │   └── 20160811175305-add-users-table.up.sql
│   ├── public
│   │   ├── css
│   │   │   └── screen.css
│   │   ├── favicon.ico
│   │   ├── img
│   │   └── js
│   ├── sql
│   │   └── queries.sql
│   └── html
│       ├── about.html
│       ├── base.html
│       ├── error.html
│       └── home.html
├── src
│   └── clj
│       └── guestbook
│           ├── config.clj
│           ├── core.clj        #web program entry to control start and stop
│           ├── db
│           │   └── core.clj    #Functions for storing interactions with databases
│           ├── handler.clj     #The basic entry and route of the program are defined
│           ├── layout.clj      #Namespace rendered for page
│           ├── middleware.clj  #Namespace of program Middleware
│           └── routes
│               └── home.clj    #Define the namespace of the route for the program home page and introduction page
└── test
    └── clj
        └── guestbook
            └── test
                ├── db
                │   └── core.clj
                └── handler.clj

Posted by suge on Mon, 02 Dec 2019 23:41:56 -0800