diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
index c954cec..4465bd9 100644
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -1 +1 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
+distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
diff --git a/README.md b/README.md
index 2b09400..3897cfe 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-# springboot-java8
-The project is made on spring boot. The project summarize the new features present in Java 8.
+# springboot-java15
+The project is made on spring boot. The project summarizes the features present in Java 8 through Java 15.
It contain list of harcoded topics list. You can call the apis's with POSTMAN to add,delete,update Topic list
In addition, it uses
1) Java 8 NIO methods
@@ -13,6 +13,8 @@ In addition, it uses
9) Default and Static methods in interface
10) Java 8 LocalDateTime API
11) Pattern
+12) Java 10+ local variable type inference (var)
+13) Java 15 text blocks
@@ -76,13 +78,12 @@ GET /datetime
### Prerequisites
-1) Java sdk
+1) Java 15 SDK
2) POSTMAN
### Installing
-
```
1) Download or clone
2) Import the project
@@ -129,6 +130,4 @@ https://dzone.com/articles/java-8-friday-goodies-new-new
## Authors
-* **Rehman Murad Ali**
-
-
+* **Rehman Murad Ali**
diff --git a/build.gradle b/build.gradle
index 09f1083..6839889 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE")
+ classpath("org.springframework.boot:spring-boot-gradle-plugin:2.7.18")
}
}
@@ -14,19 +14,20 @@ apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
- baseName = 'gs-spring-boot'
- version = '0.1.0'
+ archiveBaseName = 'gs-spring-boot'
+ archiveVersion = '0.1.0'
}
repositories {
mavenCentral()
}
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
+sourceCompatibility = 15
+targetCompatibility = 15
dependencies {
- compile("org.springframework.boot:spring-boot-starter-web")
- testCompile("junit:junit")
+ implementation("org.springframework.boot:spring-boot-starter-web")
+ implementation("org.springframework.boot:spring-boot-starter-jdbc")
+ runtimeOnly("com.h2database:h2")
+ testImplementation("junit:junit")
}
-
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a2ff3cc..03a8d13 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755
diff --git a/mvnw b/mvnw
old mode 100644
new mode 100755
diff --git a/pom.xml b/pom.xml
index 63f5cbd..9e270a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,13 +5,13 @@
org.springframework
gs-spring-boot
- pom
+ jar
0.1.0
org.springframework.boot
spring-boot-starter-parent
- 2.0.2.RELEASE
+ 2.7.18
@@ -35,12 +35,20 @@
- 1.8
+ 15
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 15
+
+
org.springframework.boot
spring-boot-maven-plugin
diff --git a/src/main/java/hello/Application.java b/src/main/java/hello/Application.java
index 7cf8faf..eed9f0a 100644
--- a/src/main/java/hello/Application.java
+++ b/src/main/java/hello/Application.java
@@ -25,19 +25,25 @@ public class Application implements CommandLineRunner {
public static void main(String[] args) {
- ApplicationContext ctx = SpringApplication.run(Application.class, args);
-
+ var ctx = SpringApplication.run(Application.class, args);
+
System.out.println("Let's inspect the beans provided by Spring Boot:");
-
- String[] beanNames = ctx.getBeanDefinitionNames();
+
+ var beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
- for (String beanName : beanNames) {
+ for (var beanName : beanNames) {
System.out.println(beanName);
}
- RestTemplate restTemplate = new RestTemplate();
- Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
- log.info(quote.toString());
+ try {
+ var restTemplate = new RestTemplate();
+ var quote = restTemplate.getForObject("https://dummyjson.com/quotes/random", Quote.class);
+ if (quote != null) {
+ log.info(quote.toString());
+ }
+ } catch (Exception e) {
+ log.warn("Could not fetch quote from external service: {}", e.getMessage());
+ }
}
@@ -49,9 +55,15 @@ public RestTemplate restTemplate(RestTemplateBuilder builder) {
@Bean
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
return args -> {
- Quote quote = restTemplate.getForObject(
- "http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
- log.info(quote.toString());
+ try {
+ var quote = restTemplate.getForObject(
+ "https://dummyjson.com/quotes/random", Quote.class);
+ if (quote != null) {
+ log.info(quote.toString());
+ }
+ } catch (Exception e) {
+ log.warn("Could not fetch quote from external service: {}", e.getMessage());
+ }
};
}
@@ -64,23 +76,26 @@ public void run(String... args) throws Exception {
log.info("Creating tables");
jdbcTemplate.execute("DROP TABLE customers IF EXISTS");
- jdbcTemplate.execute("CREATE TABLE customers(id SERIAL, first_name VARCHAR(255), last_name VARCHAR(255))");
-
- // Split up the array of whole names into an array of first/last names
- List