Giter VIP home page Giter VIP logo

lein-servlet's Introduction

lein-servlet

A Leiningen 2 plugin to work with servlet-based webapps.

You may use this plugin to launch a servlet-based webapp using a suitable servlet engine adapter, or generate a war/uberwar file. Adapters for Jetty-7, Jetty-8, Jetty-9, Tomcat-7 and Tomcat-8 are provided.

NOTE: This plugin is meant only to work with servlets based web apps. For idiomatic web development using Clojure you should consider lein-ring and ring.

Usage

It takes multi-line configuration in project.clj to use lein-servlet. For example, a minimal configuration might look like this:

:plugins [[lein-servlet "0.4.0"]]
:servlet {:deps    [[lein-servlet/adapter-jetty7 "0.4.0"]]
          :webapps {"/" {:servlets {"/*" com.myapp.WebServlet}
                         :public   "public"}}}

Given the servlet class exists in classpath and the directory public exists too, when you run lein servlet run, it starts the Jetty servlet container with the webapp at http://localhost:3000/

Creating a project via templates

In many cases you may be using lein-servlet templates that are actually project skeletons of several types.

You do not need to have any plugin installed to create a template. Unless you already have a version of lein-servlet/lein-template, the following commands automatically download the latest version for use.

The command to create lein-servlet project skeletons is:

lein new lein-servlet [flavor] project-name

Both flavor and project-name are placeholders for the actual names to be used. Note that flavor is optional and indicates a project type. Currently the flavor can be either of quercus, railo and struts. See examples:

$ lein new lein-servlet foo          # creates a simple Clojure/servlet webapp
$ lein new lein-servlet quercus foo  # creates a Clojure/PHP webapp that uses Quercus
$ lein new lein-servlet railo foo    # creates a Clojure/CFML webapp that uses Railo
$ lein new lein-servlet struts foo   # creates a Clojure/Java webapp that uses Struts1

Regular configuration

The recommended use of lein-servlet is as a project-level plugin. Put [lein-servlet "0.3.0"] into the :plugins vector of your project.clj.

If you must use this as a user-level plugin, put [lein-servlet "0.4.0"] into the :plugins vector of your :user profile.

For a detail list of all possible configuration options please check the file sample.project.clj.

Command-line usage

To view the configured servlet engine:

$ lein servlet engine

To start all configured webapps using the configured servlet engine:

$ lein servlet run  # opens server homepage in browser

To generate a WAR file:

$ lein servlet war     # generates target/<filename>.war file with sources only
$ lein servlet uberwar # generates target/<filename>.war file with dependencies

Contributors

  • Shantanu Kumar (author)
  • Sean Corfield

Getting in touch

Leiningen mailing list: https://groups.google.com/group/leiningen/

Twitter: https://twitter.com/kumarshantanu

E-mail: kumar.shantanu(at)gmail.com

License

Copyright © 2012-2014 Shantanu Kumar and contributors

Distributed under the Eclipse Public License, the same as Clojure.

lein-servlet's People

Contributors

kumarshantanu avatar seancorfield avatar juergenhoetzel avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.