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
1answer
59 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 ...
2
votes
1answer
47 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
1answer
35 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
0answers
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 ...
0
votes
0answers
82 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 ...
1
vote
0answers
19 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 ...
3
votes
0answers
131 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
1answer
118 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 ...
3
votes
2answers
95 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 ...
2
votes
1answer
86 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
1answer
221 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 ...
1
vote
0answers
73 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
0answers
45 views

java integration test wait for websocket message and verify content

I am following some java training where I am asked to write a websocket server which accepts orders to be placed and matched with previous orders. The matching engine is unit tested separately. There ...
0
votes
1answer
44 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
0answers
21 views

Idempotent Processing of Messages

Code ...
0
votes
0answers
64 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 ...
1
vote
0answers
28 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
2answers
160 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
1answer
72 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
1answer
70 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
0answers
49 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
1answer
71 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
1answer
190 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
2answers
205 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. ...
1
vote
1answer
584 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 ...
3
votes
0answers
92 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 ...
7
votes
1answer
68 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 ...
3
votes
1answer
51 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
1answer
91 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
2answers
96 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 ...
1
vote
0answers
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....
2
votes
2answers
109 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 ...
1
vote
1answer
36 views

Repository and service improvements

I have a MongoRepository: ...
6
votes
2answers
79 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: ...
2
votes
0answers
51 views

Elastic search Java

Below is a json schema I have in elastic search ...
2
votes
2answers
245 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 ...
2
votes
0answers
34 views

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

I have a Spring service that calls a few methods to ...
1
vote
1answer
40 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 ...
3
votes
1answer
397 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: ...
2
votes
1answer
117 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 ...
3
votes
1answer
201 views

Meme (title with picture) exchanger

Project structure without code: Packages: Classes in packages: In ConfigConstants I store path to folder, where I save pictures. Also in ...
1
vote
0answers
60 views

Flatten nested lists in Java

I'm developing a complex app with Spring Boot and MongoDB. I have a Video class like the following. Note: All getters setters are omitted. ...
11
votes
2answers
574 views

Stack Overflow clone

I have to write a simple web application using the Java Spring framework as my course project. So I decided to write a simple Stack Overflow clone. My application has the following features: ...
1
vote
2answers
367 views

Return a 404 when a resource is not found in Spring Boot

I wrote this code in order to return a http status of not found to my users in case the resource is not present in the DB. ...
2
votes
0answers
73 views

Java Spring web application

Here is a Java Spring web application built as an educational project that fetches and displays data returned from NASA's Mars Weather Service API. The project is essentially an attempt to reverse ...
3
votes
0answers
92 views

Learning Spring framework with Thymeleaf

I would like to ask you to point me some good direction with writing clean code with Spring framework and Java in general. I am creating a simple app, which has two main features: searching for beers ...
3
votes
0answers
35 views

Separation of database and network calls

I have a API and the corresponding service method is like this: ...
1
vote
3answers
268 views

User Id generator

Hi guys below is my code to generate random long unique Ids, I use System.nanoTime to generate long Id but now to make sure that it doesn't clash in the database with previously created Id I get all ...
3
votes
2answers
73 views

Find all classes A that implement B<T> and aggregate both A and T to build a map out of them

In my project I have the following base interfaces used through the application: interface Node { /* ... */ } interface NodeService<T> { /* ... */ } ...

1
2 3 4 5