Skip to content

Commit

Permalink
feat : apply spring boot best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Aug 31, 2024
1 parent 0ffcb96 commit 60a83ce
Show file tree
Hide file tree
Showing 51 changed files with 138 additions and 78 deletions.
2 changes: 1 addition & 1 deletion batch-boot-jpa-sample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion boot-api-archunit-sample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion boot-choas-monkey/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
3 changes: 2 additions & 1 deletion boot-grafana-lgtm/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
spring.application.name=boot-grafana-lgtm
spring.application.name=boot-grafana-lgtm
spring.threads.virtual.enabled=true

management.endpoints.web.exposure.include=env,health,info,logfile,loggers,metrics,prometheus
management.tracing.sampling.probability=1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.restassured.RestAssured;
import io.restassured.authentication.PreemptiveBasicAuthScheme;
import io.restassured.http.ContentType;
import org.apache.http.HttpStatus;
import org.apache.hc.core5.http.HttpStatus;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
2 changes: 1 addition & 1 deletion boot-mongodb-elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion boot-opensearch-sample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion boot-rest-docs-sample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion boot-togglz-sample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.ultimateredis.config;

import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
Expand All @@ -12,7 +11,6 @@ public class RedisValueOperationsUtil<T> {
private final RedisTemplate<String, T> redisTemplate;
private final ValueOperations<String, T> valueOperations;

@Autowired
public RedisValueOperationsUtil(RedisTemplate<String, T> redisTemplate) {
this.redisTemplate = redisTemplate;
this.valueOperations = redisTemplate.opsForValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public ResponseEntity<GenericResponse<Boolean>> addRedisKeyValue(
}

@GetMapping
public ResponseEntity<GenericResponse<String>> getFromCache(
@RequestParam(value = "key") String key) {
public ResponseEntity<GenericResponse<String>> getFromCache(@RequestParam String key) {

String value = redisService.getValue(key);
return ResponseEntity.ok(new GenericResponse<>(value));
Expand Down
2 changes: 1 addition & 1 deletion graphql/boot-graphql-querydsl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion graphql/boot-graphql-webflux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion graphql/boot-graphql-webmvc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion httpClients/boot-http-proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion httpClients/boot-rest-template/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion httpClients/boot-web-client-mvc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion httpClients/boot-web-client-webflux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion jpa/boot-data-customsequence/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion jpa/boot-data-envers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import io.restassured.http.ContentType;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpStatus;
import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpStatus;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
Expand Down
2 changes: 1 addition & 1 deletion jpa/boot-data-keyset-pagination/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
2 changes: 1 addition & 1 deletion jpa/boot-hibernate2ndlevelcache-sample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ class CustomerController {

@GetMapping
PagedResult<CustomerResponse> getAllCustomers(
@RequestParam(value = "pageNo", defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false)
int pageNo,
@RequestParam(value = "pageSize", defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false)
int pageSize,
@RequestParam(value = "sortBy", defaultValue = AppConstants.DEFAULT_SORT_BY, required = false)
String sortBy,
@RequestParam(value = "sortDir", defaultValue = AppConstants.DEFAULT_SORT_DIRECTION, required = false)
String sortDir) {
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false) int pageNo,
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false) int pageSize,
@RequestParam(defaultValue = AppConstants.DEFAULT_SORT_BY, required = false) String sortBy,
@RequestParam(defaultValue = AppConstants.DEFAULT_SORT_DIRECTION, required = false) String sortDir) {
FindCustomersQuery findCustomersQuery = new FindCustomersQuery(pageNo, pageSize, sortBy, sortDir);
return customerService.findAllCustomers(findCustomersQuery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ class OrderController {

@GetMapping
PagedResult<OrderResponse> getAllOrders(
@RequestParam(value = "pageNo", defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false)
int pageNo,
@RequestParam(value = "pageSize", defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false)
int pageSize,
@RequestParam(value = "sortBy", defaultValue = AppConstants.DEFAULT_SORT_BY, required = false)
String sortBy,
@RequestParam(value = "sortDir", defaultValue = AppConstants.DEFAULT_SORT_DIRECTION, required = false)
String sortDir) {
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false) int pageNo,
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false) int pageSize,
@RequestParam(defaultValue = AppConstants.DEFAULT_SORT_BY, required = false) String sortBy,
@RequestParam(defaultValue = AppConstants.DEFAULT_SORT_DIRECTION, required = false) String sortDir) {
FindOrdersQuery findOrdersQuery = new FindOrdersQuery(pageNo, pageSize, sortBy, sortDir);
return orderService.findAllOrders(findOrdersQuery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ class OrderItemController {

@GetMapping
PagedResult<OrderItemResponse> getAllOrderItems(
@RequestParam(value = "pageNo", defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false)
int pageNo,
@RequestParam(value = "pageSize", defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false)
int pageSize,
@RequestParam(value = "sortBy", defaultValue = AppConstants.DEFAULT_SORT_BY, required = false)
String sortBy,
@RequestParam(value = "sortDir", defaultValue = AppConstants.DEFAULT_SORT_DIRECTION, required = false)
String sortDir) {
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false) int pageNo,
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false) int pageSize,
@RequestParam(defaultValue = AppConstants.DEFAULT_SORT_BY, required = false) String sortBy,
@RequestParam(defaultValue = AppConstants.DEFAULT_SORT_DIRECTION, required = false) String sortDir) {
FindOrderItemsQuery findOrderItemsQuery = new FindOrderItemsQuery(pageNo, pageSize, sortBy, sortDir);
return orderItemService.findAllOrderItems(findOrderItemsQuery);
}
Expand Down
2 changes: 1 addition & 1 deletion jpa/boot-jndi-sample/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ public class DriverController {

@GetMapping
public PagedResult<DriverResponse> getAllDrivers(
@RequestParam(value = "pageNo", defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false)
int pageNo,
@RequestParam(value = "pageSize", defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false)
int pageSize,
@RequestParam(value = "sortBy", defaultValue = AppConstants.DEFAULT_SORT_BY, required = false)
String sortBy,
@RequestParam(value = "sortDir", defaultValue = AppConstants.DEFAULT_SORT_DIRECTION, required = false)
String sortDir) {
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_NUMBER, required = false) int pageNo,
@RequestParam(defaultValue = AppConstants.DEFAULT_PAGE_SIZE, required = false) int pageSize,
@RequestParam(defaultValue = AppConstants.DEFAULT_SORT_BY, required = false) String sortBy,
@RequestParam(defaultValue = AppConstants.DEFAULT_SORT_DIRECTION, required = false) String sortDir) {
FindDriversQuery findDriversQuery = new FindDriversQuery(pageNo, pageSize, sortBy, sortDir);
return driverService.findAllDrivers(findDriversQuery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ server.shutdown=graceful
spring.main.allow-bean-definition-overriding=true
spring.jmx.enabled=false
spring.mvc.problemdetails.enabled=true
spring.threads.virtual.enabled=true

################ Actuator #####################
management.endpoints.web.exposure.include=configprops,env,health,info,logfile,loggers,metrics,prometheus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void shouldFetchAllDrivers() throws Exception {

@Test
void shouldFindDriverById() throws Exception {
Driver driver = driverList.get(0);
Driver driver = driverList.getFirst();
Long driverId = driver.getId();

this.mockMvc
Expand Down Expand Up @@ -104,7 +104,7 @@ void shouldReturn400WhenCreateNewDriverWithoutText() throws Exception {

@Test
void shouldUpdateDriver() throws Exception {
Long driverId = driverList.get(0).getId();
Long driverId = driverList.getFirst().getId();
DriverRequest driverRequest = new DriverRequest("Updated Driver");

this.mockMvc
Expand All @@ -118,7 +118,7 @@ void shouldUpdateDriver() throws Exception {

@Test
void shouldDeleteDriver() throws Exception {
Driver driver = driverList.get(0);
Driver driver = driverList.getFirst();

this.mockMvc
.perform(delete("/api/drivers/{id}", driver.getId()))
Expand Down
2 changes: 1 addition & 1 deletion jpa/boot-jpa-locks/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,26 @@ public static void setReplicaRoute() {
protected Object determineCurrentLookupKey() {
return routeContext.get();
}

public boolean isWrapperFor(Class<?> iface) throws java.sql.SQLException {
// TODO Auto-generated method stub
return iface != null && iface.isAssignableFrom(this.getClass());
}

public <T> T unwrap(Class<T> iface) throws java.sql.SQLException {
// TODO Auto-generated method stub
try {
if (iface != null && iface.isAssignableFrom(this.getClass())) {
return (T) this;
}
throw new java.sql.SQLException("Auto-generated unwrap failed; Revisit implementation");
} catch (Exception e) {
throw new java.sql.SQLException(e);
}
}

public java.util.logging.Logger getParentLogger() {
// TODO Auto-generated method stub
return null;
}
}
2 changes: 1 addition & 1 deletion jpa/multitenancy/multidatasource-multitenancy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,26 @@ public class TenantRoutingDatasource extends AbstractRoutingDataSource {
protected String determineCurrentLookupKey() {
return tenantIdentifierResolver.resolveCurrentTenantIdentifier();
}

public boolean isWrapperFor(Class<?> iface) throws java.sql.SQLException {
// TODO Auto-generated method stub
return iface != null && iface.isAssignableFrom(this.getClass());
}

public <T> T unwrap(Class<T> iface) throws java.sql.SQLException {
// TODO Auto-generated method stub
try {
if (iface != null && iface.isAssignableFrom(this.getClass())) {
return (T) this;
}
throw new java.sql.SQLException("Auto-generated unwrap failed; Revisit implementation");
} catch (Exception e) {
throw new java.sql.SQLException(e);
}
}

public java.util.logging.Logger getParentLogger() {
// TODO Auto-generated method stub
return null;
}
}
2 changes: 1 addition & 1 deletion jpa/multitenancy/multitenancy-db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
6 changes: 6 additions & 0 deletions jpa/multitenancy/multitenancy-db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
Expand Down
Loading

0 comments on commit 60a83ce

Please sign in to comment.