Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/.idea/
/.idea/
target/
.gradle/
build/
37 changes: 17 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE")
}
plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'org.springframework.boot' version '3.3.13'
id 'io.spring.dependency-management' version '1.1.7'
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
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
java {
toolchain {
languageVersion = JavaLanguageVersion.of(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 'org.springframework.boot:spring-boot-starter-test'
}

12 changes: 4 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@

<groupId>org.springframework</groupId>
<artifactId>gs-spring-boot</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<version>0.1.0</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<version>3.3.13</version>
<relativePath/>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -35,7 +31,7 @@
</dependencies>

<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
</properties>


Expand Down
20 changes: 11 additions & 9 deletions src/main/java/hello/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ 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());
}


Expand All @@ -47,11 +44,15 @@ public RestTemplate restTemplate(RestTemplateBuilder builder) {
}

@Bean
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
public CommandLineRunner quoteRunner(RestTemplate restTemplate) {
return args -> {
Quote quote = restTemplate.getForObject(
"http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
log.info(quote.toString());
try {
Quote quote = restTemplate.getForObject(
"https://quoters.apps.pcfone.io/api/random", Quote.class);
log.info(String.valueOf(quote));
} catch (Exception e) {
log.warn("Quote service unavailable: {}", e.getMessage());
}
};
}

Expand Down Expand Up @@ -80,8 +81,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()));

}
Expand Down
Binary file removed target/classes/hello/Application.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed target/classes/hello/declaration/CustomPredicate.class
Binary file not shown.
Binary file removed target/classes/hello/declaration/TimeClient.class
Binary file not shown.
Binary file removed target/classes/hello/model/Customer.class
Binary file not shown.
Binary file removed target/classes/hello/model/Greeting.class
Binary file not shown.
Binary file removed target/classes/hello/model/Quote.class
Binary file not shown.
Binary file removed target/classes/hello/model/SimpleTimeClient.class
Binary file not shown.
Binary file removed target/classes/hello/model/Topic.class
Binary file not shown.
Binary file removed target/classes/hello/model/Value.class
Binary file not shown.
Binary file removed target/classes/hello/service/TopicService.class
Binary file not shown.
10 changes: 0 additions & 10 deletions target/classes/public/index.html

This file was deleted.