Skip to content
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

Update to JAVA 21 + SpringBoot 3.3.0 #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
11 changes: 4 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
<version>3.3.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>br.ce.wcaquino</groupId>
<artifactId>tasks-frontend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>tasks-frontend</name>
<description>A very simple task management tool</description>

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

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/br/ce/wcaquino/tasksfrontend/ServletInitializer.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package br.ce.wcaquino.tasksfrontend.controller;
package br.ce.wcaquino.tasksfrontend.controller;

import java.util.List;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -27,7 +27,7 @@ public class TasksController {
private String VERSION;

public String getBackendURL() {
return "http://" + BACKEND_HOST + ":" + BACKEND_PORT;
return "http://" + BACKEND_HOST + ":" + BACKEND_PORT + "/tasks-backend";
}

@GetMapping("")
Expand All @@ -49,8 +49,8 @@ public String save(Todo todo, Model model) {
try {
RestTemplate restTemplate = new RestTemplate();
restTemplate.postForObject(
getBackendURL() + "/tasks-backend/todo", todo, Object.class);
model.addAttribute("sucess", "Sucess!");
getBackendURL() + "/todo", todo, Object.class);
model.addAttribute("success", "Success!");
return "index";
} catch(Exception e) {
Pattern compile = Pattern.compile("message\":\"(.*)\",");
Expand All @@ -67,7 +67,7 @@ public String save(Todo todo, Model model) {
@GetMapping("delete/{id}")
public String delete(@PathVariable Long id, Model model) {
RestTemplate restTemplate = new RestTemplate();
restTemplate.delete(getBackendURL() + "/tasks-backend/todo/" + id);
restTemplate.delete(getBackendURL() + "/todo/" + id);
model.addAttribute("success", "Success!");
model.addAttribute("todos", getTodos());
return "index";
Expand All @@ -78,6 +78,6 @@ public String delete(@PathVariable Long id, Model model) {
private List<Todo> getTodos() {
RestTemplate restTemplate = new RestTemplate();
return restTemplate.getForObject(
getBackendURL() + "/tasks-backend/todo", List.class);
getBackendURL() + "/todo", List.class);
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
server.port=8002
spring.application.name=tasks-frontend

backend.host=${BACKEND_HOST:127.0.0.1}
backend.port=${BACKEND_PORT:8001}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h1>Tasks</h1>
<p class="lead">A very simple task management tool</p>
</div>
<p class="alert alert-success" role="alert" th:if="${sucess != null}" th:text="${sucess}" id="message" />
<p class="alert alert-success" role="alert" th:if="${success != null}" th:text="${success}" id="message" />
<div th:switch="${todos.size()}">
<h2 th:case="0">No tasks... enjoy your day!</h2>
<div th:case="*">
Expand Down