Demonstrates some capabilities of the Spring Boot framework through a small, simple example. After reviewing this example, you should have a good understanding of what Spring Boot can do and get a feel for how easy it is to use. #Features:
- Spring Boot 2.7.x, supporting fully executable JARs for Linux based operating systems
- WebFlux rest controller to generate qrcode images
- Produces binary Content-Type (PNG)
- HTTP header manipulation (Cache-Control)
- Java Exception translation to HTTP status code
- Manual cache eviction (HTTP DELETE)
- CORS enabled (GET, DELETE)
- Reactive processing (for the image creation)
- Uses the Fast Java QrCode Generator library by nayuki.
- Spring IoC (Service, Autowired)
- Backend caching (Spring "simple" memory-based ConcurrentHashMap)
- Scheduled tasks. Automatic cache eviction, every 30 minutes.
- Logging (sl4j + logback)
- Only 2 classes, about 100 lines of code!!!
- Small. Final JAR includes everything (it self-contained) and it's about 18 MB
Clone the repository:
$ git clone https://github.com/raonigabriel/spring-qrcode-example.git
If this is your first time using Github, review http://help.github.com to learn the basics.
From the command line with Maven:
$ cd spring-qrcode-example
$ mvn spring-boot:run
From the command line with Linux:
$ cd spring-qrcode-example/target
$ ./spring-qrcode-example-x.y.z.jar
Using docker:
$ docker run -d --name qrcode-service --rm -p 8080:8080 raonigabriel/spring-qrcode-example
Access the deployed web application http://localhost:8080/qrcode?text=Hello%20World%20From%20Spring
or
In your preferred IDE such as SpringSource Tool Suite (STS) or IDEA:
- Import spring-qrcode-example as a Maven Project
Code on package "com.github.raonigabriel" (my code) is released under the Apache 2.0 license
Code under on "io.nayuki.fastqrcodegen" (nayuki code) is released under the MIT license
- This code comes with no warranty. Use it at your own risk.
- I don't like Apple. Fuck off, fan-boys.
- I don't like left-winged snowflakes. Fuck off, code-covenant.
- I will call my branches the old way. Long live master, fuck-off renaming.