Skip to content

Commit

Permalink
feat : upgrade to spring boot 3.4.0 and delombok (#1556)
Browse files Browse the repository at this point in the history
* feat : upgrade to spring boot 3.4.0

* feat : remove lombok
  • Loading branch information
rajadilipkolli authored Dec 5, 2024
1 parent 60f0a62 commit 7ce45a3
Show file tree
Hide file tree
Showing 18 changed files with 435 additions and 164 deletions.
18 changes: 5 additions & 13 deletions boot-mongodb-elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.6</version>
<version>3.4.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.mongoes</groupId>
Expand All @@ -19,7 +19,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>21</java.version>
<springdoc-openapi.version>2.6.0</springdoc-openapi.version>
<springdoc-openapi.version>2.7.0</springdoc-openapi.version>

<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<spotless.version>2.43.0</spotless.version>
Expand Down Expand Up @@ -53,11 +53,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
Expand All @@ -78,11 +74,7 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>


<dependency>
<groupId>org.springdoc</groupId>
Expand Down Expand Up @@ -229,7 +221,7 @@
<configuration>
<java>
<googleJavaFormat>
<version>1.23.0</version>
<version>1.25.0</version>
<style>AOSP</style>
</googleJavaFormat>
</java>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,64 @@
package com.example.mongoes.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Data
@ConfigurationProperties("application")
public class ApplicationProperties {
private Cors cors = new Cors();

@Data
public Cors getCors() {
return cors;
}

public void setCors(Cors cors) {
this.cors = cors;
}

public static class Cors {
private String pathPattern = "/api/**";
private String allowedMethods = "*";
private String allowedHeaders = "*";
private String allowedOriginPatterns = "*";
private boolean allowCredentials = true;

public String getPathPattern() {
return pathPattern;
}

public void setPathPattern(String pathPattern) {
this.pathPattern = pathPattern;
}

public String getAllowedMethods() {
return allowedMethods;
}

public void setAllowedMethods(String allowedMethods) {
this.allowedMethods = allowedMethods;
}

public String getAllowedHeaders() {
return allowedHeaders;
}

public void setAllowedHeaders(String allowedHeaders) {
this.allowedHeaders = allowedHeaders;
}

public String getAllowedOriginPatterns() {
return allowedOriginPatterns;
}

public void setAllowedOriginPatterns(String allowedOriginPatterns) {
this.allowedOriginPatterns = allowedOriginPatterns;
}

public boolean isAllowCredentials() {
return allowCredentials;
}

public void setAllowCredentials(boolean allowCredentials) {
this.allowCredentials = allowCredentials;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
value = ReactiveElasticsearchRepository.class))
public class DataStoreConfiguration {
class DataStoreConfiguration {

@Bean
ReactiveMongoTransactionManager transactionManager(ReactiveMongoDatabaseFactory factory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
import com.example.mongoes.utils.AppConstants;
import com.example.mongoes.web.service.RestaurantService;
import java.io.IOException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.annotation.Profile;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
@Profile(AppConstants.PROFILE_NOT_TEST)
public class Initializer implements CommandLineRunner {

private static final Logger log = LoggerFactory.getLogger(Initializer.class);
private final RestaurantService restaurantService;

public Initializer(RestaurantService restaurantService) {
this.restaurantService = restaurantService;
}

@Override
public void run(String... args) throws IOException {
log.info("Running Initializer.....");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Configuration(proxyBeanMethods = false)
@OpenAPIDefinition(info = @Info(title = "spring-boot-mongodb-elasticsearch", version = "v1"))
public class SwaggerConfig {
class SwaggerConfig {

@Bean
OpenAPI openAPI() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package com.example.mongoes.config;

import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.web.config.SpringDataJacksonConfiguration;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;

@Configuration
@RequiredArgsConstructor
@Configuration(proxyBeanMethods = false)
@Import(SpringDataJacksonConfiguration.class)
public class WebFluxConfig implements WebFluxConfigurer {

private final ApplicationProperties properties;

public WebFluxConfig(ApplicationProperties properties) {
this.properties = properties;
}

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping(properties.getCors().getPathPattern())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package com.example.mongoes.document;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.StringJoiner;
import org.springframework.data.elasticsearch.annotations.GeoPointField;
import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexType;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexed;
import org.springframework.data.mongodb.core.mapping.Field;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Address {

private String building;
Expand All @@ -29,7 +23,6 @@ public class Address {
* </code>
* </pre>
*/
@JsonDeserialize(as = Point.class)
@GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_2DSPHERE)
@GeoPointField
@org.springframework.data.elasticsearch.annotations.Field("coord")
Expand All @@ -39,4 +32,46 @@ public class Address {
private String street;

private Integer zipcode;

public String getBuilding() {
return building;
}

public void setBuilding(String building) {
this.building = building;
}

public Point getLocation() {
return location;
}

public void setLocation(Point location) {
this.location = location;
}

public String getStreet() {
return street;
}

public void setStreet(String street) {
this.street = street;
}

public Integer getZipcode() {
return zipcode;
}

public void setZipcode(Integer zipcode) {
this.zipcode = zipcode;
}

@Override
public String toString() {
return new StringJoiner(", ", Address.class.getSimpleName() + "[", "]")
.add("building='" + building + "'")
.add("location=" + location)
.add("street='" + street + "'")
.add("zipcode=" + zipcode)
.toString();
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
package com.example.mongoes.document;

import lombok.Getter;
import lombok.Setter;
import org.bson.BsonTimestamp;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Document
@Getter
@Setter
public class ChangeStreamResume {

@Id private String id;

private BsonTimestamp resumeTimestamp;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public BsonTimestamp getResumeTimestamp() {
return resumeTimestamp;
}

public void setResumeTimestamp(BsonTimestamp resumeTimestamp) {
this.resumeTimestamp = resumeTimestamp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.StringJoiner;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Grades {
private String grade;

Expand All @@ -23,4 +18,45 @@ public class Grades {
private LocalDateTime date;

private Integer score;

public Grades() {}

public Grades(String grade, LocalDateTime date, Integer score) {
this.grade = grade;
this.date = date;
this.score = score;
}

public LocalDateTime getDate() {
return date;
}

public void setDate(LocalDateTime date) {
this.date = date;
}

public String getGrade() {
return grade;
}

public void setGrade(String grade) {
this.grade = grade;
}

public Integer getScore() {
return score;
}

public void setScore(Integer score) {
this.score = score;
}

@Override
public String toString() {
return new StringJoiner(", ", Grades.class.getSimpleName() + "[", "]")
.add("date=" + date)
.add("grade='" + grade + "'")
.add("score=" + score)
.toString();
}
}
Loading

0 comments on commit 7ce45a3

Please sign in to comment.