Pre-requisitess:
- Set up a VM with Ubuntu 20.04
- Update and upgrade packages
apt-get update
apt-get upgrade
- Navigate to root
sudo su
- Install GIT
apt install git
- Install JAVA 1.8.0
apt-get install openjdk-8-jdk
- Install MAven
apt-get install maven
- Install MYSQL server
apt-get update
apt-get install mysql-server
systemctl start mysql.service
- Install MySQL Client
apt-get install mysql-client
- Configure root username and password for MYSQL
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password123';
exit
Setup Database:
- Connect to MYSQL server and create below database
mysql -uroot -ppassword123
CREATE DATABASE springboot_mysql_example;
SHOW DATABASES;
exit
Application Build and Deployment:
- Clone source code in to ubuntu machine
- Configuration changes in application properties files Navigate to "application.properties" file and open
cd spring-boot-mysql-example/src/main/resources/
vi application.properties
Ensure below entries have correct MYSQL Connection credentials:
spring.datasource.url= jdbc:mysql://localhost:3306/springboot_mysql_example?useSSL=false
spring.datasource.username= root
spring.datasource.password= password123
SAVE the file and EXIT
- Build the application Navigate to root folder of the application. Change path location according to your machine
cd spring-boot-mysql-example
mvn install
Expected Output: [INFO] BUILD SUCCESS
- Validate build Navigate to target folder
cd spring-boot-mysql-example/target
JAR file (spring-boot-mysql-0.0.1-SNAPSHOT.jar) must present in Target folder
- RUN JAR File
cd spring-boot-mysql-example/target
java -jar spring-boot-mysql-0.0.1-SNAPSHOT.jar
Expected Output: Started SpringBootMySqlApplication in 6.593 seconds (JVM running for 7.206)
- Browse Application: http://192.168.200.135:8080/ Change IP to Ubuntu machine IP