Questions tagged [spring]

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Filter by
Sorted by
Tagged with
1 vote
0 answers
47 views

Reactive JWT authentication using Spring webflux

Greeting to all senior devs here. I'm trying to create a project for my small business. There are not many tutorial on how to create Reactive JWT authentication with Spring webflux. So I'm a bit ...
  • 291
0 votes
0 answers
30 views

ResponseEntity return json object

...
  • 1
0 votes
0 answers
61 views

A simple event sourcing application using postgres and kafka as an event store

I am creating a simple banking application using event sourcing and CQRS. The application uses postgres and kafka as an event store. The source code can be found at source. Currently, the application ...
1 vote
1 answer
56 views

Read from dynamic source and caching

I want to load JSON data from a link at the beginning of an application. I need to be a little bit about clear the following code. And also want to ask about another opinions that what could be the ...
0 votes
0 answers
27 views

Java utility which forwards a request to an error handler mapping

I have a class ErrorForward which is basically a utility. It's used in Servlets, inside the catch block. It forwards request to <...
0 votes
0 answers
44 views

Simple project of Spring-RestController

I'm learning how to build a project from a scratch by using Spring Rest Controller but I need to get a feedback to learn from my mistakes or overengineering parts. This is my controller; ...
1 vote
1 answer
241 views

Collect and combine results of async calls returning completable futures in Java in a cleaner way?

I need an abstract way to implement this below functionality because in my code I have to use it in multiple places with different REST endpoints. If I ignore it will cause code duplication. Please ...
1 vote
0 answers
346 views

Spring Boot Integration Test with SQS and Elastic Search

I have the following integration test that starts with sending message to sqs queue and ends with checking elastic search if the associated object added to db. The part of application I want to test ...
  • 53
1 vote
2 answers
272 views

Using Factory Design Pattern in Rest Controller of Spring

I used factory design pattern to identify the service according to the enum that comes from the api uri as request param. Everything seems okay according to me but cannot be sure if I used it right. <...
-1 votes
1 answer
59 views

Using Factory Design Pattern in Spring [closed]

I organized the factory design pattern but I'm not sure if I used it right or wrong. Here's my data model; ...
0 votes
0 answers
30 views

Reactive Spring Cloud Stream WebSocket Source Service

This was the first time I dipped my toes into Spring Cloud Stream in combination with reactive programming via a reactive WebSocket client. It works in terms of general functionality - A subscriber to ...
  • 201
3 votes
1 answer
78 views

A controller for a Game Service

I have a Spring MVC controller but I'm not sure that it is a good or bad design. As far as I know, api versioning is missing but apart from that I implemented Swagger for documentation and added ...
  • 31
3 votes
2 answers
76 views

Search code that performs in-memory search

This is the code I came across in our repository. This performs search in-memory and is invoked on service layer code. In our front end operators like EQUAL_TO and ...
1 vote
1 answer
82 views

Cleaning Kotlin method which returns the document name after the id

I'm just getting to know the possibilities of Kotlin and mongoDB. I am writing a method that returns the name of the street after the ID. Everything works, but I find it quite sloppy. Empty String ...
  • 35
0 votes
1 answer
530 views

Spring boot: better way to handle response and exceptions

I am working on a quite a big Spring Boot web service and I wanted a standardized and simplified way to handle responses and exceptions by following fluent API design. So this is what I did and it ...
1 vote
1 answer
88 views

Refactoring duplicated code with abstraction and generics

I have written simple command line project with Spring. And from what I think quality of code is pretty poor. I see what I could improve to remove duplicated code, but somehow I have no idea what ...
  • 85
2 votes
1 answer
183 views

Simple game of Chutes and Ladders

I recently made a new project for Chutes and Ladders (the Hasbro version of Snakes and ladders) and it is located here: https://github.com/vchittar/ChutesAndLadders BoardLogic (implements an interface)...
0 votes
1 answer
43 views

Spring-WebFlux code to save per-user data [closed]

I'm using Spring-WebFlux with Spring-Security and I need to save data depending on the currently registered user. In order to do so, in my controller, I need to retrieve the data sent from both the ...
2 votes
0 answers
36 views

How to check gcp pupsub empty/inactitve subscribtion

I have an application that subscribes to a topic in GCP and when there is some messages over there it downloads them and sends them to a queue on ActiveMQ. In order to make this process fast I am ...
1 vote
0 answers
23 views

Spring Boot Elastic Seemingly ignoring second Query

I have some code I've written which I need a review of (if possible) as I know I have a bug somewhere. Most likely due to my (lack) of understanding of some concepts in ElasticSearch and Spring. For ...
  • 153
5 votes
0 answers
559 views

Exception handling: using @JsonProperty value to make error message

If the validation in RestController fails, I need to handle MethodArgumentNotValidException and provide an errorMessage, that ...
2 votes
1 answer
145 views

How can I rewrite the below parser code in Java

I have written a simple parser in Java for a study project. Can anyone see how I might improve the code below. I have been looking at the code myself for the last few days but I couldn't come up with ...
  • 31
4 votes
2 answers
185 views

Spring Boot API - Avoiding Concurrency issues

I'm still in the process of learning Java / spring and I think I'm getting better. Now at this point I'm able to build a rest api BUT I'm at a lost at how to ensure I've no concurrency issues . I've ...
  • 153
2 votes
1 answer
485 views

Bank exercise with Java Spring Boot and JPA

I'm constructing a homework from my Spring Boot Course and so far I did the JPA layer and want to have some feedback, before start the business rules, about if the I could improve something or change ...
1 vote
1 answer
1k views

Handling multiple optional parameters in Spring

I have an endpoint in my RestAPI which can receive 3 optional parameters and then find information in the database with these parameters, also it is possible to combine the parameters. So, in my ...
  • 13
1 vote
0 answers
89 views

Signing in with "Remember me" option implemented with Spring and Kotlin

I'm trying to implement authentication with "Remember me" option using Spring and Kotlin. I would really appriciate if someone could help me find potential issues with that implementation as ...
0 votes
1 answer
53 views

How do I divide Dao and Dao-Cache into different modules? [closed]

I want to improve performance for api. I design cache in dao layer. I use caffine cache. Basic code is: CacheConfig.java ...
2 votes
0 answers
24 views

Idempotent Processing of Messages

Code ...
  • 143
0 votes
1 answer
97 views

Dynamically choose bean without Qualifier annotation

I have a service that gets an URL from the user input, extracts the body content of this URL, apply CSS, and finally returns the result as a stream. The tricky part is that I have different ...
  • 71
1 vote
0 answers
37 views

Implement Kafka Communication with Serialized Java objects

I want to implement Kafka Topic which sends and receives Serialized Java Objects based on this example. I tried this: Producer Config: ...
4 votes
2 answers
181 views

Are these Unit tests OK or am I implementing an antipattern or not following best practices

I am testing a Spring boot service using JUnit 5 and Mockito. I haven't spent much time on unit testing in the past so I'm not sure if I'm accidentally implementing an anti-pattern or not following ...
1 vote
1 answer
84 views

What to test on a rest API?

I created a rest controller with Spring Boot, I am trying to learn what I should write on my tests, right now I only check status codes and keys existence. I am planning to build an API to showcase at ...
1 vote
1 answer
215 views

An efficient way to order content in controller [Spring Boot]

My code works as intended. CategoryController class has getAllCategories method, which tells ContentOrderMap class to map differently ordered categories to their respective OrderType enum. The ...
1 vote
0 answers
83 views

What is the best way to call two async functions, one after another in spring?

Very new to spring and spring boot here... What would be the best practice for calling two async functions one after another? If I have three functions like this : ...
2 votes
1 answer
119 views

Suitable way for Validating JPA Entities in Spring Boot

I have been around in Spring Boot eco-system since 2012, I have worked on many little projects. The most important thing in development I experienced id Validation ...
0 votes
1 answer
981 views

Spring Boot should we always use interfaces even with one implementation [closed]

quick question. I'm using Spring Boot and I created e.g. this class ...
2 votes
2 answers
237 views

API call return type and error handling [closed]

I wrote the following method which would just call an API which would then update a user's subscription to something. ...
  • 123
1 vote
1 answer
1k views

Sonar: Move constants to a class or enum [closed]

I found one project on Internet and after I downloaded it, I got this message from SonarQube: Move constants to a class or enum. But, when I downloaded ...
  • 183
3 votes
0 answers
114 views

Migrate customer and transaction data from CSV to MongoDB

I wrote a Java Spring Boot application with MongoDB that on every application start loads customer, account type and transaction details from CSV files to MongoDB. It has one end point that returns ...
6 votes
1 answer
78 views

Persistent waiting room

This is an exercise to implement a waiting room for an hospital with the following requirements: Add (and remove) a patient to the queue of the waiting room Move a patient up and down the queue Show ...
  • 5,487
4 votes
1 answer
79 views

SpringBoot application to send notification via phone numbers on SMS

I'm using Spring boot - 2.3.3.RELEASE and gradle. Note- I'm using Factory and Strategy pattern. This project is going to be used as a Library for other projects to import and use the methods exposed ...
0 votes
1 answer
113 views

Microservice in Springboot

I wrote two microservices in Springboot and tried to follow the best practices. I would appreciate any suggestions about any improvement that I can make on the whole codebase. What are the parts of ...
2 votes
2 answers
106 views

Designing object oriented clean code structure with spring services

I'm writing spring app for storing and manipulating recipes. I wrote ShoppingList service which generates, based on UUIDs of recipes, shopping list. This is my current model for which i wrote tests ...
  • 21
1 vote
0 answers
27 views

Microservice unit testing database script insert Error - H2 [closed]

For unit testing my ProductList service, I tried run a script to insert some data and then try to get this data and compare the list size. But my database insert script is not running and returns null....
2 votes
2 answers
197 views

Loan application service based on user credit score

The following microservice is just handling loan application and response the result of the application is accepted or rejected. It is part of my assignment for an interview. The project description ...
  • 180
1 vote
1 answer
45 views

Repository and service improvements

I have a MongoRepository: ...
  • 209
1 vote
1 answer
131 views

In Spring framework, should the controller let the client know that something went wrong by returning a response entity with the proper error code?

Category Service: ...
7 votes
2 answers
97 views

Refactoring validator system

I've validator system that validates input data before saving to DB. So let's say I want to create new user. We are at the service class: ...
1 vote
0 answers
53 views

Elastic search Java

Below is a json schema I have in elastic search ...
2 votes
2 answers
929 views

Get all data from an external and paginated Swagger API using Java / Feign / Spring

I have written the following method that allows me to import from another API all the items stored there using Feign. The only issue is that the external API provides a size limit of 2000 and ...
  • 799

1
2 3 4 5