From 331469e8cf6960de3c73276166d5290dfafdb857 Mon Sep 17 00:00:00 2001 From: eis Date: Mon, 10 Apr 2023 14:57:47 +0300 Subject: [PATCH 1/2] Spring Boot 3, Java 17 only --- .github/workflows/github-actions-build.yml | 4 ++-- Dockerfile | 6 ++---- pom.xml | 12 ++++++------ src/main/java/example/counter/CounterRequest.java | 2 +- .../java/example/counter/CounterRestController.java | 4 ++-- src/main/resources/templates/counter.html | 6 +++--- src/main/resources/templates/greeting.html | 6 +++--- .../java/example/counter/CounterRequestTest.java | 8 ++++---- ubuntu-deps.sh | 2 +- 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/github-actions-build.yml b/.github/workflows/github-actions-build.yml index 2c93ad6..f33869b 100755 --- a/.github/workflows/github-actions-build.yml +++ b/.github/workflows/github-actions-build.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ '8', '11', '17' ] + java: [ '17' ] name: Java ${{ matrix.Java }} build with Maven env: @@ -46,7 +46,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'adopt' - java-version: '11' + java-version: '17' - name: Coverage with Jacoco Maven plugin run: mvn verify jacoco:report --quiet --batch-mode -DbuildNumber=${GITHUB_RUN_NUMBER} - uses: codecov/codecov-action@v1 diff --git a/Dockerfile b/Dockerfile index 164c233..9b8556c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ -# java:8 is 600M+, alpine < 200M -# FROM java:8 - -FROM adoptopenjdk/openjdk11:alpine-slim +# java:8 containers are 600M+, alpine < 200M +FROM openjdk/17-jdk-slim EXPOSE 8080 COPY target/spring-boot-example-1.0-SNAPSHOT.jar /app.jar diff --git a/pom.xml b/pom.xml index 96bc55b..8e851c5 100755 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.8 + 3.0.5 Simple Spring Boot app to get started. @@ -68,12 +68,12 @@ org.webjars bootstrap - 3.3.7 + 3.4.0 org.webjars jquery - 1.12.4 + 3.6.2 @@ -86,8 +86,8 @@ org.springdoc - springdoc-openapi-ui - 1.7.0 + springdoc-openapi-starter-webmvc-ui + 2.1.0 @@ -238,7 +238,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.9 diff --git a/src/main/java/example/counter/CounterRequest.java b/src/main/java/example/counter/CounterRequest.java index 59d665c..bd9f6d3 100644 --- a/src/main/java/example/counter/CounterRequest.java +++ b/src/main/java/example/counter/CounterRequest.java @@ -1,6 +1,6 @@ package example.counter; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import lombok.Data; diff --git a/src/main/java/example/counter/CounterRestController.java b/src/main/java/example/counter/CounterRestController.java index b36fec5..b8cded3 100755 --- a/src/main/java/example/counter/CounterRestController.java +++ b/src/main/java/example/counter/CounterRestController.java @@ -1,6 +1,6 @@ package example.counter; -import javax.validation.Valid; +import jakarta.validation.Valid; import io.swagger.v3.oas.annotations.Operation; import org.springframework.http.MediaType; @@ -12,7 +12,7 @@ @RestController @RequestMapping( - produces = MediaType.APPLICATION_JSON_UTF8_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public class CounterRestController { public static final String ADD_URL = "/counter/add"; diff --git a/src/main/resources/templates/counter.html b/src/main/resources/templates/counter.html index 1a546cf..8358a77 100755 --- a/src/main/resources/templates/counter.html +++ b/src/main/resources/templates/counter.html @@ -6,10 +6,10 @@ + href="/webjars/bootstrap/3.4.0/css/bootstrap.min.css" /> - - + + diff --git a/src/main/resources/templates/greeting.html b/src/main/resources/templates/greeting.html index 7bf71c3..51ac819 100755 --- a/src/main/resources/templates/greeting.html +++ b/src/main/resources/templates/greeting.html @@ -5,7 +5,7 @@ + href="/webjars/bootstrap/3.4.0/css/bootstrap.min.css" /> @@ -40,9 +40,9 @@

+ src="/webjars/jquery/3.6.2/jquery.min.js"> + src="/webjars/bootstrap/3.4.0/js/bootstrap.min.js"> \ No newline at end of file diff --git a/src/test/java/example/counter/CounterRequestTest.java b/src/test/java/example/counter/CounterRequestTest.java index 72acfda..b21d468 100755 --- a/src/test/java/example/counter/CounterRequestTest.java +++ b/src/test/java/example/counter/CounterRequestTest.java @@ -3,10 +3,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import jakarta.validation.ValidatorFactory; import java.util.Set; import static org.junit.Assert.assertFalse; diff --git a/ubuntu-deps.sh b/ubuntu-deps.sh index 3a0c0d9..b1c2f14 100755 --- a/ubuntu-deps.sh +++ b/ubuntu-deps.sh @@ -1,2 +1,2 @@ apt-get update -apt-get install -y openjdk-8-jdk maven +apt-get install -y openjdk-17-jdk maven From 5c2e5c06c985294cb07c46da09a177d1b8cfc509 Mon Sep 17 00:00:00 2001 From: eis Date: Mon, 10 Apr 2023 15:32:14 +0300 Subject: [PATCH 2/2] HTML UI tweaks --- .../resources/static/css/counter-style.css | 7 +-- src/main/resources/templates/counter.html | 16 ++++++- src/main/resources/templates/greeting.html | 48 +++++++++---------- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/main/resources/static/css/counter-style.css b/src/main/resources/static/css/counter-style.css index a77e5cb..1ce7266 100755 --- a/src/main/resources/static/css/counter-style.css +++ b/src/main/resources/static/css/counter-style.css @@ -1,17 +1,14 @@ -* { +body { background-color: #eee; } .vertical-center { - min-height: 100%; /* Fallback for browsers do NOT support vh unit */ + min-height: 100%; /* Fallback for browsers who do NOT support vh unit */ min-height: 100vh; /* These two lines are counted as one :-) */ display: flex; flex-direction: column; justify-content: center; } -.container { - width: 100%; -} #result { border: solid #dadada 2px; padding: 2px; diff --git a/src/main/resources/templates/counter.html b/src/main/resources/templates/counter.html index 8358a77..47bdf16 100755 --- a/src/main/resources/templates/counter.html +++ b/src/main/resources/templates/counter.html @@ -13,7 +13,21 @@ -
+ + +
diff --git a/src/main/resources/templates/greeting.html b/src/main/resources/templates/greeting.html index 51ac819..dccb62b 100755 --- a/src/main/resources/templates/greeting.html +++ b/src/main/resources/templates/greeting.html @@ -12,37 +12,33 @@ + - - -
- -
-

Spring Boot Web Thymeleaf Example

-

- -

-
- -
- - - + + \ No newline at end of file