diff --git a/.gitignore b/.gitignore
index 57f1cb2..171f386 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
-/.idea/
\ No newline at end of file
+/.idea/
+/target/
+/build/
+/.gradle/
diff --git a/README.md b/README.md
index 2b09400..e85d3ae 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.
+The project is made on Spring Boot 3.x running on Java 17. The project summarizes the new features that were originally introduced in Java 8.
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
@@ -76,9 +76,11 @@ GET /datetime
### Prerequisites
-1) Java sdk
+1) Java 17 SDK
2) POSTMAN
+> Note: This project now targets Spring Boot 3.x, which requires Java 17 or newer.
+
### Installing
diff --git a/build.gradle b/build.gradle
index 09f1083..fbf6aec 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:3.2.5")
}
}
@@ -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 = 17
+targetCompatibility = 17
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..a595206 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Thu Mar 01 09:01:15 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755
diff --git a/pom.xml b/pom.xml
index 63f5cbd..2d4d1be 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,15 +11,10 @@
org.springframework.boot
spring-boot-starter-parent
- 2.0.2.RELEASE
+ 3.2.5
-
- org.springframework.boot
- spring-boot-properties-migrator
- runtime
-
org.springframework.boot
spring-boot-starter-web
@@ -35,7 +30,7 @@
- 1.8
+ 17
diff --git a/src/main/java/hello/Application.java b/src/main/java/hello/Application.java
index 7cf8faf..34dff48 100644
--- a/src/main/java/hello/Application.java
+++ b/src/main/java/hello/Application.java
@@ -5,18 +5,14 @@
import java.util.stream.Collectors;
import hello.model.Customer;
-import hello.model.Quote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.web.client.RestTemplate;
@SpringBootApplication
public class Application implements CommandLineRunner {
@@ -26,33 +22,14 @@ public class Application implements CommandLineRunner {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
-
+
System.out.println("Let's inspect the beans provided by Spring Boot:");
-
+
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String 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());
- }
-
-
- @Bean
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
- return builder.build();
- }
-
- @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());
- };
}
@@ -63,7 +40,7 @@ public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
public void run(String... args) throws Exception {
log.info("Creating tables");
- jdbcTemplate.execute("DROP TABLE customers IF EXISTS");
+ jdbcTemplate.execute("DROP TABLE IF EXISTS customers");
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
@@ -80,8 +57,9 @@ public void run(String... args) throws Exception {
log.info("Querying for customer records where first_name = 'Josh':");
jdbcTemplate.query(
- "SELECT id, first_name, last_name FROM customers WHERE first_name = ?", new Object[]{"Josh"},
- (rs, rowNum) -> new Customer(rs.getLong("id"), rs.getString("first_name"), rs.getString("last_name"))
+ "SELECT id, first_name, last_name FROM customers WHERE first_name = ?",
+ (rs, rowNum) -> new Customer(rs.getLong("id"), rs.getString("first_name"), rs.getString("last_name")),
+ "Josh"
).forEach(customer -> log.info(customer.toString()));
}
diff --git a/src/main/java/hello/model/Quote.java b/src/main/java/hello/model/Quote.java
deleted file mode 100644
index 2178a6d..0000000
--- a/src/main/java/hello/model/Quote.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package hello.model;
-
-public class Quote {
- private String type;
- private Value value;
-
- @Override
- public String toString() {
- return "Quote{" +
- "type='" + type + '\'' +
- ", value=" + value +
- '}';
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public Value getValue() {
- return value;
- }
-
- public void setValue(Value value) {
- this.value = value;
- }
-
- public Quote() {
-
- }
-}
diff --git a/src/main/java/hello/model/Value.java b/src/main/java/hello/model/Value.java
deleted file mode 100644
index 272be70..0000000
--- a/src/main/java/hello/model/Value.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package hello.model;
-
-public class Value {
- private Long id;
- private String quote;
-
- public Value() {
- }
-
- @Override
- public String toString() {
- return "Value{" +
- "id=" + id +
- ", quote='" + quote + '\'' +
- '}';
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getQuote() {
- return quote;
- }
-
- public void setQuote(String quote) {
- this.quote = quote;
- }
-}
diff --git a/target/classes/hello/Application.class b/target/classes/hello/Application.class
deleted file mode 100644
index 245a020..0000000
Binary files a/target/classes/hello/Application.class and /dev/null differ
diff --git a/target/classes/hello/controller/GreetingController.class b/target/classes/hello/controller/GreetingController.class
deleted file mode 100644
index 1149660..0000000
Binary files a/target/classes/hello/controller/GreetingController.class and /dev/null differ
diff --git a/target/classes/hello/controller/HelloController.class b/target/classes/hello/controller/HelloController.class
deleted file mode 100644
index 79b82ce..0000000
Binary files a/target/classes/hello/controller/HelloController.class and /dev/null differ
diff --git a/target/classes/hello/controller/TopicController.class b/target/classes/hello/controller/TopicController.class
deleted file mode 100644
index c32cad5..0000000
Binary files a/target/classes/hello/controller/TopicController.class and /dev/null differ
diff --git a/target/classes/hello/declaration/CustomPredicate.class b/target/classes/hello/declaration/CustomPredicate.class
deleted file mode 100644
index e35803f..0000000
Binary files a/target/classes/hello/declaration/CustomPredicate.class and /dev/null differ
diff --git a/target/classes/hello/declaration/TimeClient.class b/target/classes/hello/declaration/TimeClient.class
deleted file mode 100644
index a077c3b..0000000
Binary files a/target/classes/hello/declaration/TimeClient.class and /dev/null differ
diff --git a/target/classes/hello/model/Customer.class b/target/classes/hello/model/Customer.class
deleted file mode 100644
index 06e7307..0000000
Binary files a/target/classes/hello/model/Customer.class and /dev/null differ
diff --git a/target/classes/hello/model/Greeting.class b/target/classes/hello/model/Greeting.class
deleted file mode 100644
index f875277..0000000
Binary files a/target/classes/hello/model/Greeting.class and /dev/null differ
diff --git a/target/classes/hello/model/Quote.class b/target/classes/hello/model/Quote.class
deleted file mode 100644
index 3ec6c6c..0000000
Binary files a/target/classes/hello/model/Quote.class and /dev/null differ
diff --git a/target/classes/hello/model/SimpleTimeClient.class b/target/classes/hello/model/SimpleTimeClient.class
deleted file mode 100644
index f9bdddd..0000000
Binary files a/target/classes/hello/model/SimpleTimeClient.class and /dev/null differ
diff --git a/target/classes/hello/model/Topic.class b/target/classes/hello/model/Topic.class
deleted file mode 100644
index 3a53aa5..0000000
Binary files a/target/classes/hello/model/Topic.class and /dev/null differ
diff --git a/target/classes/hello/model/Value.class b/target/classes/hello/model/Value.class
deleted file mode 100644
index 862a68f..0000000
Binary files a/target/classes/hello/model/Value.class and /dev/null differ
diff --git a/target/classes/hello/service/TopicService.class b/target/classes/hello/service/TopicService.class
deleted file mode 100644
index b9f4992..0000000
Binary files a/target/classes/hello/service/TopicService.class and /dev/null differ
diff --git a/target/classes/public/index.html b/target/classes/public/index.html
deleted file mode 100644
index 566549b..0000000
--- a/target/classes/public/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
- Title
-
-
-
-
-
\ No newline at end of file