Sign inSign up

blissnd/spring-web-server

By blissnd

•Updated over 9 years ago

Java Spring Web Server demo + MySQL Database bindings + Thymeleaf HTML template iteration over DB

Image
0

10K+

blissnd/spring-web-server repository overview

⁠[docker-compose.yml]

version: '2' services: web: build: . ports: - "443:443"

======================================================================================

⁠[dockerfile]

FROM blissnd/spring-web-server CMD service mysql start && java -jar /home/spring/spring_test/target/gs-serving-web-content-0.1.0.jar

=====================================================================================

Usage:

docker-compose up

=====================================================================================

Point your web browser (from the host) to:

This is a very simple example of mapping to an HTML template within the Spring framework


Put the following URL in your web browser:

This is an example of using a URL route to fetch all rows from an example table in the back-end MySQL database and return to the client browser in JSON format.


Now put the following URL in your web browser:

This is an example of pulling the rows from same back-end MySQL table into a Thymeleaf HTML template, which iterates over the Java DB model, i.e.:


Now, add a new entry to the database:

And view the result:


To persist the database after the docker container shuts down:

docker commit <YOUR_CONTAINER_ID> blissnd/spring-web-server


Study the source code and config files in combination with the spring.io tutorials on their spring website. Here is the directory structure of the project:

-- spring_test |-- build.gradle |-- gradle | -- wrapper | |-- gradle-wrapper.jar | -- gradle-wrapper.properties |-- gradlew |-- gradlew.bat |-- keystore.jks |-- mvnw |-- mvnw.cmd |-- pom.xml |-- src | |-- main | | |-- java | | | -- hello | | | |-- Application.java | | | |-- GreetingController.java | | | |-- User.java | | | -- UserRepository.java | | -- resources | | |-- application.properties | | |-- keystore.jks | | |-- static | | | -- index.html | | -- templates | | |-- greeting.html | | -- users.html | -- test | -- java | -- hello | -- ApplicationTest.java -- target

Tag summary

Content type

Image

Digest

Size

515.9 MB

Last updated

over 9 years ago

docker pull blissnd/spring-web-server