-
Notifications
You must be signed in to change notification settings - Fork 1
Source-level fixes for Spring Boot 3 / Java 17 migration #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
|
@@ -34,25 +30,6 @@ public static void main(String[] args) { | |
| 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()); | ||
| }; | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -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())); | ||
|
Comment on lines
59
to
63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Varargs query overload resolves unambiguously with a 2-arg lambda The switch to Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: Unreferenced Quote/Value model classes left behind
With the quote fetch removed,
hello.model.Quoteandhello.model.Valueare now completely unreferenced (grepshows no remaining usages outside those files). The PR intentionally keeps them, but they are dead code that will silently rot; consider deleting them in a follow-up so the migration doesn't leave orphaned model classes.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed they're dead code now. Leaving them out of this PR deliberately: the scope handed to me was to remove the fetch logic and its imports, and deleting the model classes is a separate (if trivial) call that also touches a sibling session's expectations of the tree. Happy to drop
Quote/Valuehere if the owner prefers — otherwise it's a clean follow-up.