Help Center

Java - Spring + MySQL

Spring is a framework for Java, ideal for web applications as it is optimized to run multiple services in parallel and securely in a RESTful manner. It is also compatible with other Java frameworks.

MySQL is a widely used open-source relational database management system that allows storing, organizing, and retrieving data efficiently. Developed by Oracle, MySQL offers high speed and reliability, facilitating data management through SQL queries. Its scalability, support for multiple platforms, and ability to integrate with numerous programming languages make it a popular choice for web and enterprise applications. MySQL is highly customizable and has an active developer community that contributes to its continuous improvement.

Project structure

text
.
β”œβ”€β”€ app
β”‚Β Β  β”œβ”€β”€ pom.xml
β”‚Β Β  β”œβ”€β”€ src
β”‚Β Β  β”‚Β Β  └── main
β”‚Β Β  β”‚Β Β      β”œβ”€β”€ java
β”‚Β Β  β”‚Β Β      β”‚Β Β  └── com
β”‚Β Β  β”‚Β Β      β”‚Β Β      └── company
β”‚Β Β  β”‚Β Β      β”‚Β Β          └── project
β”‚Β Β  β”‚Β Β      β”‚Β Β              β”œβ”€β”€ Application.java
β”‚Β Β  β”‚Β Β      β”‚Β Β              β”œβ”€β”€ configuration
β”‚Β Β  β”‚Β Β      β”‚Β Β              β”‚Β Β  └── DockerSecretsProcessor.java
β”‚Β Β  β”‚Β Β      β”‚Β Β              β”œβ”€β”€ controllers
β”‚Β Β  β”‚Β Β      β”‚Β Β              β”‚Β Β  └── HomeController.java
β”‚Β Β  β”‚Β Β      β”‚Β Β              β”œβ”€β”€ entity
β”‚Β Β  β”‚Β Β      β”‚Β Β              β”‚Β Β  └── Greeting.java
β”‚Β Β  β”‚Β Β      β”‚Β Β              └── repository
β”‚Β Β  β”‚Β Β      β”‚Β Β                  └── GreetingRepository.java
β”‚Β Β  β”‚Β Β      └── resources
β”‚Β Β  β”‚Β Β          β”œβ”€β”€ application.properties
β”‚Β Β  β”‚Β Β          β”œβ”€β”€ data.sql
β”‚Β Β  β”‚Β Β          β”œβ”€β”€ META-INF
β”‚Β Β  β”‚Β Β          β”‚Β Β  └── spring.factories
β”‚Β Β  β”‚Β Β          └── schema.sql
β”‚Β Β  └── target
β”‚Β Β      └── classes
β”‚Β Β          β”œβ”€β”€ application.properties
β”‚Β Β          β”œβ”€β”€ com
β”‚Β Β          β”‚Β Β  └── company
β”‚Β Β          β”‚Β Β      └── project
β”‚Β Β          β”‚Β Β          β”œβ”€β”€ Application.class
β”‚Β Β          β”‚Β Β          β”œβ”€β”€ configuration
β”‚Β Β          β”‚Β Β          β”‚Β Β  └── DockerSecretsProcessor.class
β”‚Β Β          β”‚Β Β          β”œβ”€β”€ controllers
β”‚Β Β          β”‚Β Β          β”‚Β Β  └── HomeController.class
β”‚Β Β          β”‚Β Β          β”œβ”€β”€ entity
β”‚Β Β          β”‚Β Β          β”‚Β Β  └── Greeting.class
β”‚Β Β          β”‚Β Β          └── repository
β”‚Β Β          β”‚Β Β              └── GreetingRepository.class
β”‚Β Β          β”œβ”€β”€ data.sql
β”‚Β Β          β”œβ”€β”€ META-INF
β”‚Β Β          β”‚Β Β  └── spring.factories
β”‚Β Β          └── schema.sql
β”œβ”€β”€ app.Dockerfile
β”œβ”€β”€ compose.yaml
β”œβ”€β”€ nginx
β”‚Β Β  └── default.conf
β”œβ”€β”€ backup
β”‚Β Β  └── backup-runner.sh
β”œβ”€β”€ .env
└── .env.example

Application deployment:

We navigate to the directory that contains the files needed to build the container:

cd /root/stack/python/nextjs

And bring the application up:

text
docker compose up -d

Useful commands:

View running containers:

text
docker compose ps

Stop and remove the application:

text
docker compose down

Rebuild the application after making code changes:

text
docker compose up -d --build
Guide g.0285 Β· Source version 1 Β· en