Help Center

Java - Spring + MySQL

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

MySQL is an open-source relational database management system widely used 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 community of developers who contribute 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
β”œβ”€β”€ db
β”‚Β Β  └── password.txt
└── README.txt

Application deployment:

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

cd /root/stack/python/nextjs

And start the application:

text
docker compose up -d

Useful commands:

View the containers that are running:

text
docker compose ps

Stop and remove the application:

text
docker compose down

Rebuild the application after making changes to the code:

text
docker compose --build -d