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
votes
0answers
34 views

Reducing boiler plate code (getters and setters) in a DTO modeling class [closed]

I would like to remove the getters and setters boilerplate code below but I am unsure of how to do so. I have a DTO class to model the JSON column questionVariables ...
-2
votes
0answers
14 views

spring batch multiple inputfiles in environment variables [closed]

I need serious help please i'm stuck for 3 days now in same problem i have to code a spring batch program that read multiple csv files and copy their content into an output file. My batch ...
2
votes
0answers
20 views

Idempotent Processing of Messages

Code ...
0
votes
0answers
58 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
21 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
140 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
67 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
55 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
46 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
63 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
50 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
173 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
224 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
91 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
66 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
46 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
84 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
85 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
24 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
103 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
35 views

Repository and service improvements

I have a MongoRepository: ...
6
votes
2answers
78 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
75 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
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
81 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
54 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
364 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
69 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
71 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
90 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
34 views

Separation of database and network calls

I have a API and the corresponding service method is like this: ...
1
vote
3answers
109 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
71 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
402 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
112 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
773 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
67 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
846 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
124 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
231 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
190 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
69 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 ...
2
votes
1answer
62 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 ...

1
2 3 4 5