Skip to content
Merged
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
32 changes: 14 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.google.protobuf.gradle.id

plugins {
id("org.springframework.boot") version "3.5.8"
id("org.springframework.boot") version "4.0.0"
id("io.spring.dependency-management") version "1.1.7"
id("org.graalvm.buildtools.native") version "0.11.1"
id("org.jetbrains.kotlin.jvm") version "2.2.21"
Expand All @@ -26,22 +26,21 @@ repositories {
mavenCentral()
}

extra["testcontainersVersion"] = "2.0.2"
extra["jjwtVersion"] = "0.12.6"
extra["testcontainersVersion"] = "1.21.3"
extra["jjwtVersion"] = "0.13.0"

dependencies {
// Spring Boot Starters
implementation("org.springframework.boot:spring-boot-starter-web") {
exclude(group = "org.springframework.boot", module = "spring-boot-starter-tomcat")
}
implementation("org.springframework.boot:spring-boot-starter-undertow")
implementation("org.springframework.boot:spring-boot-starter-webmvc")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.14")
implementation("org.springframework.boot:spring-boot-starter-jackson")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.0")

// Database
implementation("org.springframework.boot:spring-boot-starter-flyway")
runtimeOnly("org.postgresql:postgresql:42.7.8")
runtimeOnly("org.flywaydb:flyway-database-postgresql:11.11.1")

Expand All @@ -56,31 +55,28 @@ dependencies {
developmentOnly("org.springframework.boot:spring-boot-docker-compose")

// Testing
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "junit", module = "junit")
}
testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test")
testImplementation("org.springframework.boot:spring-boot-starter-webflux-test") // For WebTestClient
testImplementation("org.springframework.boot:spring-boot-starter-data-jpa-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.springframework.boot:spring-boot-testcontainers")
testImplementation("org.junit.jupiter:junit-jupiter:5.13.3")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:postgresql")
testImplementation("io.rest-assured:rest-assured:5.5.6")
testImplementation("io.rest-assured:json-path:5.5.6")

// Swagger
implementation("io.swagger.core.v3:swagger-models:2.2.34")
implementation("io.swagger.core.v3:swagger-core:2.2.34")
implementation("javax.xml.bind:jaxb-api:2.3.1")
implementation("com.sun.xml.bind:jaxb-impl:2.3.9")
implementation("jakarta.xml.bind:jakarta.xml.bind-api:4.0.2")
runtimeOnly("org.glassfish.jaxb:jaxb-runtime:4.0.5")

// gRPC and Protobuf
implementation("io.grpc:grpc-netty-shaded:1.77.0")
implementation("io.grpc:grpc-protobuf:1.77.0")
implementation("io.grpc:grpc-stub:1.77.0")
implementation("com.google.protobuf:protobuf-java:4.33.1")
// Because protobuf is still using javax annotations
implementation("javax.annotation:javax.annotation-api:1.3.2")
implementation("net.devh:grpc-server-spring-boot-starter:3.1.0.RELEASE")
implementation("jakarta.annotation:jakarta.annotation-api:3.0.0")
implementation("org.springframework.grpc:spring-grpc-spring-boot-starter:1.0.0")
}

dependencyManagement {
Expand Down
10 changes: 10 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

Move `@EnableJpaAuditing` to a separate configuration class `JpaAuditingConfig.java` so that we can exclude it from
testings. Otherwise it will throw errors when testing controllers:

```
Caused by: java.lang.IllegalArgumentException: JPA metamodel must not be empty
at org.springframework.util.Assert.notEmpty(Assert.java:398)
```

## Rest Assured - not support Spring Boot 4

Rest Assured 5.5.6 doesn't work with Groovy 5 (still use Groovy 4), which is not compatible with Spring Boot 4(uses
Groovy 5).
We need to replace Rest Assured with `WebTestClient` before Rest Assured's upgrade.

- [Remove integration for REST Docs' REST Assured support until REST Assured supports Groovy 5](https://github.com/spring-projects/spring-boot/issues/47685)
- [Drop support for REST Assured until it supports Groovy 5](https://github.com/spring-projects/spring-restdocs/issues/1000)
2 changes: 1 addition & 1 deletion gradle/jacoco.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ val strictCoverageClasses = listOf(
)

tasks.named<JacocoReport>("jacocoTestReport") {
dependsOn(tasks.named("test"))
dependsOn(tasks.named("test"), tasks.named("processResources"), tasks.named("compileJava"))
reports {
xml.required.set(true) // For CI/CD integration
html.required.set(true) // For human-readable reports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.config.MeterFilter;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.micrometer.metrics.autoconfigure.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.nkcoder.infrastructure.security;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.jsonwebtoken.ExpiredJwtException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
Expand All @@ -13,6 +12,7 @@
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import tools.jackson.databind.ObjectMapper;

@Component
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
Expand Down
40 changes: 11 additions & 29 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,23 @@ spring:
fetch_size: 100
generate_statistics: false

security:
oauth2:
resourceserver:
jwt:
issuer-uri: http://localhost:3001

jackson:
serialization:
write-dates-as-timestamps: false
time-zone: UTC
property-naming-strategy: LOWER_CAMEL_CASE

autoconfigure:
exclude:
- org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration

docker:
compose:
enabled: false

threads:
virtual:
enabled: true

# gRPC configuration
grpc:
server:
port: 9090
max-inbound-message-size: 4MB
max-inbound-metadata-size: 8KB
reflection:
enabled: true

# JWT Configuration
jwt:
secret:
Expand All @@ -68,10 +62,6 @@ cors:
allow-credentials: true
max-age: 3600

# Rate Limiting Configuration
rate-limit:
requests-per-window: 100
window-size-minutes: 15

# Actuator Configuration
management:
Expand Down Expand Up @@ -117,12 +107,4 @@ info:
version: '@project.version@'
description: '@project.description@'
java-version: '@java.version@'
spring-boot-version: '@parent.version@'

# grpc configuration
grpc:
server:
port: 9090
max-inbound-message-size: 4194304 # 4MB
max-inbound-metadata-size: 8192 # 8KB
reflection-service-enabled: true
spring-boot-version: '@parent.version@'
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest;
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.test.context.ActiveProfiles;
Expand Down
Loading
Loading