Clojure Spring Cloud Save

Clojure Spring Cloud Sample

Project README

Spring Cloud

Actions Status

Proof of concept Clojure Implementation of Spring Boot Getting Started

This project was created against 'Spring 2.2.5.RELEASE'

Setup

Spring Boot uses its own JarLauncher org.springframework.boot.loader.JarLauncher Maven and Gradle have plugins to package the jar for you, Leiningen does not. So I had to create a custom lein plugin.

Goto - [https://github.com/scotthaleen/lein-spring-boot-jar] and install the plugin locally to compile this project.

Note: for history I have left the custom bash script (./bin/package.sh) used before I created the lein plugin.

Compile

lein spring-boot-jar

Run

Choose a profile either dev and prod and specify it using the spring.profiles.active parameter. There is no default (intentionally) the application will fail to start when no valid profile is not specified.

$ java -jar -Dspring.profiles.active=dev target/boot-spring-cloud-0.1.0-SNAPSHOT.jar
16:04:58.120 [main] INFO spring.cloud.App -
   ____ _       _
  / ___| | ___ (_)_   _ _ __ ___
 | |   | |/ _ \| | | | | '__/ _ \
 | |___| | (_) | | |_| | | |  __/
  \____|_|\___// |\__,_|_|  \___|
              |__/



  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.5.RELEASE)
...


$ curl localhost:8080
Greetings from Clojure!%

$  curl http://localhost:8080/greeting
{"id":1,"content":"Hello, world!"}%

$ curl "http://localhost:8080/greeting?name=User"
{"id":2,"content":"Hello, User!"}%

# Depending on -Dspring.profiles.active={dev,prod}
# Without an active profile the server will fail to start
$ curl http://localhost:8080/env
dev

TODO

  • Spring Boot Lein Package Plugin
  • Spring Profiles example
  • Spring Autowiring magic

Repobeats

Alt

License

Copyright © 2024

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Open Source Agenda is not affiliated with "Clojure Spring Cloud" Project. README Source: scotthaleen/clojure-spring-cloud
Stars
36
Open Issues
0
Last Commit
4 months ago

Open Source Agenda Badge

Open Source Agenda Rating