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
0 votes
0 answers
26 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; ...
user avatar
1 vote
1 answer
97 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 ...
user avatar
1 vote
0 answers
113 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 ...
user avatar
  • 53
1 vote
2 answers
111 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. <...
user avatar
-1 votes
1 answer
52 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; ...
user avatar
0 votes
0 answers
19 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 ...
user avatar
  • 201
3 votes
1 answer
73 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 ...
user avatar
  • 31
3 votes
2 answers
70 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 ...
user avatar
1 vote
1 answer
79 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 ...
user avatar
  • 35
0 votes
1 answer
284 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 ...
user avatar
1 vote
1 answer
84 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 ...
user avatar
  • 85
2 votes
1 answer
119 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)...
user avatar
0 votes
1 answer
39 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 ...
user avatar
2 votes
0 answers
32 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 ...
user avatar
0 votes
0 answers
229 views

Spring Boot API Key Filter

I tried https://stackoverflow.com/questions/48446708/securing-spring-boot-api-with-api-key-and-secret, but that didn't work for me (filter did nothing). Since I couldn't find any useful tutorial with ...
user avatar
1 vote
0 answers
22 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 ...
user avatar
  • 153
5 votes
0 answers
400 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 ...
user avatar
2 votes
1 answer
134 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 ...
user avatar
  • 31
4 votes
2 answers
143 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 ...
user avatar
  • 153
2 votes
1 answer
334 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 ...
user avatar
1 vote
1 answer
804 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 ...
user avatar
  • 13
1 vote
0 answers
81 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 ...
user avatar
0 votes
1 answer
47 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 ...
user avatar
2 votes
0 answers
23 views

Idempotent Processing of Messages

Code ...
user avatar
  • 143
0 votes
0 answers
76 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 ...
user avatar
  • 71
1 vote
0 answers
30 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: ...
user avatar
4 votes
2 answers
169 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 ...
user avatar
1 vote
1 answer
74 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 ...
user avatar
1 vote
1 answer
169 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 ...
user avatar
1 vote
0 answers
67 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 : ...
user avatar
2 votes
1 answer
92 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 ...
user avatar
0 votes
1 answer
782 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 ...
user avatar
2 votes
2 answers
226 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. ...
user avatar
  • 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 ...
user avatar
  • 183
3 votes
0 answers
101 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 ...
user avatar
6 votes
1 answer
72 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 ...
user avatar
  • 5,487
4 votes
1 answer
69 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 ...
user avatar
0 votes
1 answer
97 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 ...
user avatar
2 votes
2 answers
102 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 ...
user avatar
  • 21
1 vote
0 answers
25 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....
user avatar
2 votes
2 answers
133 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 ...
user avatar
  • 180
1 vote
1 answer
39 views

Repository and service improvements

I have a MongoRepository: ...
user avatar
  • 209
1 vote
1 answer
124 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: ...
user avatar
7 votes
2 answers
90 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: ...
user avatar
1 vote
0 answers
52 views

Elastic search Java

Below is a json schema I have in elastic search ...
user avatar
2 votes
2 answers
649 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 ...
user avatar
  • 789
2 votes
0 answers
35 views

Collect messages from a job to send in body of one email

I have a Spring service that calls a few methods to ...
user avatar
  • 299
1 vote
1 answer
41 views

any better way than using old servlet api for downloads

I am wondering if the following code can be modified to be used with latest version of spring APIs? The following code works fine. However, I wanted to know if servlet APIs can be avoided which i have ...
user avatar
  • 243
3 votes
1 answer
409 views

The best approach to validate fields

I wonder if there is a better approach to validate the object fields. For specific types of objects some fields cannot be empty: ...
user avatar
  • 133
2 votes
1 answer
162 views

Reviewing the file download controller in spring rest

In my project, so this controller is working perfectly, my objective is to read the log file from the server which is created on daily basis, so I have to read the log file which is heavier in size ...
user avatar
  • 287

1
2 3 4 5