diff --git a/build.gradle b/build.gradle index 09f1083..2804120 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,7 +14,7 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' bootJar { - baseName = 'gs-spring-boot' + archiveBaseName = 'gs-spring-boot' version = '0.1.0' } @@ -22,11 +22,11 @@ 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") + 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/gs-spring-boot.iml b/gs-spring-boot.iml index ad195a8..828c1b0 100644 --- a/gs-spring-boot.iml +++ b/gs-spring-boot.iml @@ -1,6 +1,6 @@ - + diff --git a/pom.xml b/pom.xml index 63f5cbd..2ef2d3f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,15 +11,10 @@ org.springframework.boot spring-boot-starter-parent - 2.0.2.RELEASE + 2.7.18 - - 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..569f3d3 100644 --- a/src/main/java/hello/Application.java +++ b/src/main/java/hello/Application.java @@ -5,18 +5,15 @@ 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 { @@ -35,25 +32,11 @@ public static void main(String[] args) { 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()); - }; - } @Autowired @@ -63,7 +46,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 +63,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())); }