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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ DB_USERNAME=your-username
DB_PASSWORD=your-password
```

The `application.properties` file uses these environment variables with modern Spring Boot 3.5+ properties:
The `application.properties` file uses these environment variables with modern Spring Boot 4.0+ properties:

```properties
# Server configuration
server.forward-headers-strategy=framework

# Modern Couchbase configuration (Spring Boot 3.5+)
# Modern Couchbase configuration (Spring Boot 4.0+)
spring.couchbase.connection-string=${DB_CONN_STR}
spring.couchbase.username=${DB_USERNAME}
spring.couchbase.password=${DB_PASSWORD}
Expand Down Expand Up @@ -178,7 +178,7 @@ public class CouchbaseConfiguration extends AbstractCouchbaseConfiguration {

> _from config/CouchbaseConfiguration.java_

This configuration uses modern Spring Boot 3.5+ properties and automatically loads environment variables from `.env` files for local development. The configuration assumes you have either a locally running Couchbase server or a Couchbase Capella cluster.
This configuration uses modern Spring Boot 4.0+ properties and automatically loads environment variables from `.env` files for local development. The configuration assumes you have either a locally running Couchbase server or a Couchbase Capella cluster.

Applications deployed to production or staging environments should use less privileged credentials created using [Role-Based Access Control](https://docs.couchbase.com/go-sdk/current/concept-docs/rbac.html).
Please refer to [Managing Connections using the Java SDK with Couchbase Server](https://docs.couchbase.com/java-sdk/current/howtos/managing-connections.html) for more information on Capella and local cluster connections.
Expand Down
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'org.springframework.boot' version '3.5.7'
id 'org.springframework.boot' version '4.0.1'
id 'io.spring.dependency-management' version '1.1.7'
id 'java'
}
Expand Down Expand Up @@ -35,11 +35,13 @@ dependencies {
testCompileOnly 'org.projectlombok:lombok:'
testAnnotationProcessor 'org.projectlombok:lombok'

// swagger 3 springdoc openapi 2
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.14'
// swagger 3 springdoc openapi 3 for Spring Boot 4
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.1'


testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testImplementation 'org.springframework.boot:spring-boot-starter-restclient'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.web.filter.ForwardedHeaderFilter;

Expand All @@ -21,7 +20,7 @@
**/

@Slf4j
@SpringBootApplication(exclude = SecurityAutoConfiguration.class, proxyBeanMethods = false)
@SpringBootApplication(proxyBeanMethods = false)
@OpenAPIDefinition(info = @Info(title = TITLE, version = VERSION, description = DESCRIPTION))
public class Application implements CommandLineRunner {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;

public class RestResponsePage<T> extends PageImpl<T> {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public RestResponsePage(@JsonProperty("content") List<T> content,
@JsonProperty("number") int number,
@JsonProperty("size") int size,
@JsonProperty("totalElements") Long totalElements,
@JsonProperty("pageable") JsonNode pageable,
@JsonProperty("pageable") Object pageable,
@JsonProperty("last") boolean last,
@JsonProperty("totalPages") int totalPages,
@JsonProperty("sort") JsonNode sort,
@JsonProperty("sort") Object sort,
@JsonProperty("first") boolean first,
@JsonProperty("numberOfElements") int numberOfElements) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;

@JsonIgnoreProperties(ignoreUnknown = true)
public class RestResponseSlice<T> extends SliceImpl<T> {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public RestResponseSlice(@JsonProperty("content") List<T> content,
@JsonProperty("number") int number,
@JsonProperty("size") int size,
@JsonProperty("pageable") JsonNode pageable,
@JsonProperty("pageable") Object pageable,
@JsonProperty("last") boolean last,
@JsonProperty("sort") JsonNode sort,
@JsonProperty("sort") Object sort,
@JsonProperty("first") boolean first,
@JsonProperty("numberOfElements") int numberOfElements,
@JsonProperty("hasNext") boolean hasNext) {
@JsonProperty("hasNext") Boolean hasNext) {

// Calculate hasNext from the available information
// For Slice, hasNext is typically determined by whether we have more content
super(content, PageRequest.of(number, size), hasNext);
super(content, PageRequest.of(number, size), hasNext != null ? hasNext : !last);
}

}
6 changes: 5 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Server configuration
server.forward-headers-strategy=framework

# Modern Couchbase configuration (Spring Boot 3.5+)
# Modern Couchbase configuration (Spring Boot 4.0+)
spring.couchbase.connection-string=${DB_CONN_STR}
spring.couchbase.username=${DB_USERNAME}
spring.couchbase.password=${DB_PASSWORD}
Expand All @@ -13,3 +13,7 @@ spring.couchbase.env.timeouts.connect=10000ms

# Spring MVC configuration
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

# springdoc-openapi 3.x - enable API docs (disabled by default in 3.x)
springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.resttestclient.TestRestTemplate;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.http.HttpMethod;
Expand All @@ -25,6 +26,7 @@

@Slf4j
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureTestRestTemplate
class AirlineIntegrationTest {

@Value("${local.server.port}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.resttestclient.TestRestTemplate;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.http.HttpMethod;
Expand All @@ -27,6 +28,7 @@

@Slf4j
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureTestRestTemplate
class AirportIntegrationTest {

@Value("${local.server.port}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.resttestclient.TestRestTemplate;
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.http.HttpMethod;
Expand All @@ -27,6 +28,7 @@

@Slf4j
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureTestRestTemplate
class RouteIntegrationTest {

@Value("${local.server.port}")
Expand Down
Loading