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
6
votes
1answer
54 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
42 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
72 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
78 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
22 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
88 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
34 views

Repository and service improvements

I have a MongoRepository: ...
6
votes
2answers
75 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
50 views

Elastic search Java

Below is a json schema I have in elastic search ...
2
votes
2answers
53 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
30 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
39 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
394 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
45 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
199 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
47 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
320 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
59 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
70 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
88 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
33 views

Separation of database and network calls

I have a API and the corresponding service method is like this: ...
1
vote
3answers
90 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
70 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> { /* ... */ } ...
3
votes
1answer
167 views

Is it okay to use multiple repositories from inside a single service implementation in Spring?

I currently have two entities, Adress and Company. They both have DTOs to perform CRUD ...
1
vote
0answers
29 views

Return new thymeleaf page from controller [closed]

0 I have a web app built using Spring boot and thymeleaf. I have used only the index page so far which has different models in it and it work just fine. Now I want to add a new page. By new page I ...
-2
votes
1answer
45 views

How generate a random pojo value using reactor.core.publisher.Flux and reactor.util.function.Tuples [closed]

Firstly, take in account is my first question here in CodeReview. Any purpose misuderstanding will be highly appreciated if orientaded. Scenario: I want to answer randomly a pojo (json with two ...
2
votes
1answer
286 views

Spring, Kafka and Mongo how to create a RestController

I'm learning how to use Kafka, I've never used something similar in the past. In my job I was required to create a POC using it and integrate it to Spring Boot and save information on MongoDB (because ...
2
votes
0answers
64 views

JWT authentication system login through API

This is my first time writing an authentication system. Here's how it works, first client needs to send credential within authorization header like { Authorization : 'Basic ' + credential } through ...
5
votes
3answers
615 views

Using static final Strings for SQL Query in Spring Boot

This is regarding code quality and coding standards with respect to Spring Ecosystem. Here there are two methods: isRecordExists is using a class level static ...
2
votes
1answer
89 views

Spring boot loadbyusername

I have the following classes. I wonder if this structure makes sense in any terms especially the usage of the UserDetails class from Spring. Should I use ...
13
votes
4answers
3k views

Unit testing Video Service class

I wrote my first unit testing code on a service class using Mockito. The code looks like this: ...
2
votes
1answer
216 views

Simple REST web service

I am a young computer science student programming mainly in Java. I wrote a simple RESTful web service using Spring Boot Framework and the DDD architecture pattern. The project is a library ...
1
vote
3answers
147 views

Spring boot application web service

It's a web application. It should provide a service for entering data. Data is then evaluated and uses itself another service. It was part of an interview process where I was given that task to solve....
2
votes
1answer
63 views

Mapping a complex JSON response to two different JPA Entities

I am mapping a complex JSON response to two JPA Entity model classes using Jackson. The classes are CxExport and Mention, Mention has a Many to one relationship with CxExport I.e. Many mentions belong ...
0
votes
0answers
149 views

Is it a good idea to implement Spring GrantedAuthority in UserRole Model?

I am trying to implement an authentication via Spring Security. In all tutorials people build a List of GrantedAuthority records from the List of ...
2
votes
1answer
40 views

Java: Only log first error occurrence (with hourly reset)

I have a redis caching server. If that caching server is down, my app will query the database directly. I want to know from the logs if my caching server is not reachable. However, if I add a log ...
3
votes
3answers
149 views

Java 8 use of optional

I have two methods I'd like to improve using optional and any other tool, ...
3
votes
1answer
3k views

Simple Banking application in Spring boot, JPA, REST where balance can be transferred among predefined accounts and transaction history retrievable

I want to create a very simple banking application where (i) predefined accounts with a positive balance can send money (ii) requesting balance and a list of transactions can be found. I have ...
1
vote
0answers
60 views

Filter messages from a message stream, determine type of message and and its content and react accordingly

This code is supposed to : Read messages from a message stream Filter the messages to get the ones which certain terms Check if the message contains media or media URL checks if the media URL is an ...
2
votes
1answer
326 views

Send excel data to Kafka

I would like some one to review my code and let me know the feedback. Each Kafka Message is like as follows [{guid=id.Value1, timestamp=1386394980000, booleanValue=null, longValue=null, floatValue=...
1
vote
0answers
57 views

Pipe ResponseSpec's Body

I'm writing a utility method which pipes given ResponseSpec's body and gives to the caller a change to read it. ...
3
votes
1answer
331 views

Rest Api with generic crud operations

I am learning how to create a rest api in which I've decided to use generic for crud operation. I am attaching the code which I have written so far. Please have a look. Thanks for the review in ...
2
votes
1answer
73 views

Spring RESTful API handling errors

I made a Spring RESTful api as backend for a website. I would like to get feedback on coverage of errors and the response I return accordingly, am I using the status codes correctly? Basically ...
2
votes
1answer
56 views

Bookscraper - SpringBoot app to scrape data from online bookstores

BookstoreScraper is application based on Spring Boot. It allows to scrape data from two biggest polish online bookstores - EMPIK and MERLIN. You can scrap books within 3 options: bestsellers most ...
2
votes
2answers
263 views

Spring service for playing Rock Paper Scissors

I had created a service which does the actual play of Rock Paper Scissors. Below is the service which takes a PlayRequest and updates the State of Player objects given by the PlayerService. So the ...
1
vote
0answers
60 views

Lightweight, modular Discord bot - tips and feedback on the code?

The full project is up on GitHub. The codebase is super small as it stands. I'm brand new to reactive programming and Spring, and would mostly like insight on those two things. Asynchronous ...
3
votes
0answers
67 views

Using functional interface arguments in methods of services injected via Spring

Here is the working code for my Spring service: ...
1
vote
0answers
87 views

Spring boot for a blog REST API

I'm working on a blog REST API and I would like to get some opinions on where to place the logic for a single operation to filter posts. I have Category and Post in the model package. A category has ...
-3
votes
1answer
46 views