From e95ff4fff6d4cfbfcdeae100b53da44e6ba8aab3 Mon Sep 17 00:00:00 2001 From: Subhrodip Mohanta Date: Thu, 14 Dec 2023 00:25:21 +0100 Subject: [PATCH 1/2] Update to Spring Boot 3 --- CHANGELOG.md | 2 +- pom.xml | 4 ++-- .../config/ApplicationErrorController.java | 2 +- .../clone/twitter/entity/HashtagPosts.java | 16 ++++++------- .../subho/clone/twitter/entity/Hashtags.java | 20 ++++++++-------- .../xyz/subho/clone/twitter/entity/Likes.java | 16 ++++++------- .../xyz/subho/clone/twitter/entity/Posts.java | 24 +++++++++---------- .../xyz/subho/clone/twitter/entity/Users.java | 22 ++++++++--------- src/main/resources/application-dev.properties | 6 ++--- .../TwitterBackendApplicationTests.java | 8 ++++--- 10 files changed, 61 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index decea52..487d0b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changes This document main purpose is to list changes which might affect backwards compatibility. -It will not list all releases as Twitter Backend Java is built in a continous delivery fashion. +It will not list all releases as Twitter Backend Java is built in a continuous delivery fashion. ### 0.1.0-SNAPSHOT * Fix #1: Added GitHub Action workflows diff --git a/pom.xml b/pom.xml index 5b3c708..bdff812 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.17 + 3.2.0 @@ -51,7 +51,7 @@ ohbus hello@subho.xyz https://subho.xyz - Asia/Kolkata + Europe/Vienna diff --git a/src/main/java/xyz/subho/clone/twitter/config/ApplicationErrorController.java b/src/main/java/xyz/subho/clone/twitter/config/ApplicationErrorController.java index 34cd338..1998cf9 100644 --- a/src/main/java/xyz/subho/clone/twitter/config/ApplicationErrorController.java +++ b/src/main/java/xyz/subho/clone/twitter/config/ApplicationErrorController.java @@ -19,7 +19,7 @@ package xyz.subho.clone.twitter.config; import java.util.Map; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; import org.springframework.boot.web.servlet.error.ErrorAttributes; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java b/src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java index 3c8dfb9..39dfc93 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java @@ -20,14 +20,14 @@ import java.util.Date; import java.util.UUID; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/Hashtags.java b/src/main/java/xyz/subho/clone/twitter/entity/Hashtags.java index 5a88376..121f936 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/Hashtags.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/Hashtags.java @@ -23,16 +23,16 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Index; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/Likes.java b/src/main/java/xyz/subho/clone/twitter/entity/Likes.java index d08ed76..0eb0276 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/Likes.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/Likes.java @@ -20,14 +20,14 @@ import java.util.Date; import java.util.UUID; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/Posts.java b/src/main/java/xyz/subho/clone/twitter/entity/Posts.java index 43e91b0..1a6625e 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/Posts.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/Posts.java @@ -25,18 +25,18 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/Users.java b/src/main/java/xyz/subho/clone/twitter/entity/Users.java index b4187a2..f32365a 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/Users.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/Users.java @@ -25,17 +25,17 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Index; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 20368d0..6aa2e4c 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -51,9 +51,9 @@ spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true # Create the SQL file for initializing the database -#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create -#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=target/db/covid-help.sql -#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-source=metadata +#spring.jpa.properties.jakarta.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.jakarta.persistence.schema-generation.scripts.create-target=target/db/covid-help.sql +#spring.jpa.properties.jakarta.persistence.schema-generation.scripts.create-source=metadata # Hibernate ddl auto (create, create-drop, update): with "update" the database # schema will be automatically updated accordingly to java entities found in diff --git a/src/test/java/xyz/subho/clone/twitter/TwitterBackendApplicationTests.java b/src/test/java/xyz/subho/clone/twitter/TwitterBackendApplicationTests.java index bb50c9a..71f78f6 100644 --- a/src/test/java/xyz/subho/clone/twitter/TwitterBackendApplicationTests.java +++ b/src/test/java/xyz/subho/clone/twitter/TwitterBackendApplicationTests.java @@ -22,8 +22,10 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class TwitterBackendApplicationTests { +class DemoApplicationTests { @Test - void contextLoads() {} -} + void contextLoads() { + } + +} \ No newline at end of file From 7eb78877a88608089d75b31058a4a58d02689ef5 Mon Sep 17 00:00:00 2001 From: Subhrodip Mohanta Date: Thu, 14 Dec 2023 00:32:25 +0100 Subject: [PATCH 2/2] Removed Swagger for the time being Signed-off-by: Subhrodip Mohanta --- pom.xml | 6 ------ .../clone/twitter/TwitterBackendApplication.java | 2 -- .../twitter/config/ApplicationErrorController.java | 2 +- .../xyz/subho/clone/twitter/entity/HashtagPosts.java | 4 ++-- .../xyz/subho/clone/twitter/entity/Hashtags.java | 8 ++++---- .../java/xyz/subho/clone/twitter/entity/Likes.java | 4 ++-- .../java/xyz/subho/clone/twitter/entity/Posts.java | 12 ++++++------ .../java/xyz/subho/clone/twitter/entity/Users.java | 12 ++++++------ src/main/resources/application-dev.properties | 6 +++--- .../twitter/TwitterBackendApplicationTests.java | 6 ++---- 10 files changed, 26 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index bdff812..6db0307 100644 --- a/pom.xml +++ b/pom.xml @@ -121,12 +121,6 @@ spring-boot-starter-test test - - - io.springfox - springfox-boot-starter - 3.0.0 - diff --git a/src/main/java/xyz/subho/clone/twitter/TwitterBackendApplication.java b/src/main/java/xyz/subho/clone/twitter/TwitterBackendApplication.java index 8e9573e..c49c3f9 100644 --- a/src/main/java/xyz/subho/clone/twitter/TwitterBackendApplication.java +++ b/src/main/java/xyz/subho/clone/twitter/TwitterBackendApplication.java @@ -20,10 +20,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication -@EnableSwagger2 public class TwitterBackendApplication { public static void main(String[] args) { diff --git a/src/main/java/xyz/subho/clone/twitter/config/ApplicationErrorController.java b/src/main/java/xyz/subho/clone/twitter/config/ApplicationErrorController.java index 1998cf9..9a0c299 100644 --- a/src/main/java/xyz/subho/clone/twitter/config/ApplicationErrorController.java +++ b/src/main/java/xyz/subho/clone/twitter/config/ApplicationErrorController.java @@ -18,8 +18,8 @@ package xyz.subho.clone.twitter.config; -import java.util.Map; import jakarta.servlet.http.HttpServletRequest; +import java.util.Map; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; import org.springframework.boot.web.servlet.error.ErrorAttributes; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java b/src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java index 39dfc93..6ffa08d 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/HashtagPosts.java @@ -18,8 +18,6 @@ package xyz.subho.clone.twitter.entity; -import java.util.Date; -import java.util.UUID; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -28,6 +26,8 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; +import java.util.Date; +import java.util.UUID; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/Hashtags.java b/src/main/java/xyz/subho/clone/twitter/entity/Hashtags.java index 121f936..8922e2a 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/Hashtags.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/Hashtags.java @@ -19,10 +19,6 @@ package xyz.subho.clone.twitter.entity; import com.fasterxml.jackson.annotation.JsonIgnore; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -33,6 +29,10 @@ import jakarta.persistence.Index; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/Likes.java b/src/main/java/xyz/subho/clone/twitter/entity/Likes.java index 0eb0276..415c520 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/Likes.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/Likes.java @@ -18,8 +18,6 @@ package xyz.subho.clone.twitter.entity; -import java.util.Date; -import java.util.UUID; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -28,6 +26,8 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; +import java.util.Date; +import java.util.UUID; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/Posts.java b/src/main/java/xyz/subho/clone/twitter/entity/Posts.java index 1a6625e..228b92d 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/Posts.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/Posts.java @@ -19,12 +19,6 @@ package xyz.subho.clone.twitter.entity; import com.fasterxml.jackson.annotation.JsonIgnore; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.ElementCollection; @@ -37,6 +31,12 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/java/xyz/subho/clone/twitter/entity/Users.java b/src/main/java/xyz/subho/clone/twitter/entity/Users.java index f32365a..3dfdff2 100644 --- a/src/main/java/xyz/subho/clone/twitter/entity/Users.java +++ b/src/main/java/xyz/subho/clone/twitter/entity/Users.java @@ -19,12 +19,6 @@ package xyz.subho.clone.twitter.entity; import com.fasterxml.jackson.annotation.JsonIgnore; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.ElementCollection; @@ -36,6 +30,12 @@ import jakarta.persistence.Index; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 6aa2e4c..c7e2e68 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -29,11 +29,11 @@ # ===================================== # Set here configurations for the database connection -spring.datasource.url=jdbc:mysql://localhost:3306/twitter?createDatabaseIfNotExist=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Kolkata&useSSL=false +spring.datasource.url=jdbc:mysql://${MYSQL_DB_HOST}:${MYSQL_DB_PORT}/twitter?createDatabaseIfNotExist=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Kolkata&useSSL=false # Username and secret -spring.datasource.username=root -spring.datasource.password=root +spring.datasource.username=${MYSQL_DB_UNAME} +spring.datasource.password=${MYSQL_DB_PASSWD} # Keep the connection alive if idle for a long time (needed in production) spring.datasource.testWhileIdle=true diff --git a/src/test/java/xyz/subho/clone/twitter/TwitterBackendApplicationTests.java b/src/test/java/xyz/subho/clone/twitter/TwitterBackendApplicationTests.java index 71f78f6..75275d7 100644 --- a/src/test/java/xyz/subho/clone/twitter/TwitterBackendApplicationTests.java +++ b/src/test/java/xyz/subho/clone/twitter/TwitterBackendApplicationTests.java @@ -25,7 +25,5 @@ class DemoApplicationTests { @Test - void contextLoads() { - } - -} \ No newline at end of file + void contextLoads() {} +}