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
67 votes
2 answers
3k views

You are being watched! - Comments of Interest

You are being watched Code Review has an open system A machine that spies on you on every hour of every day I know because I built it. I designed the machine to detect suggestions to post on ...
Simon Forsberg's user avatar
14 votes
4 answers
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: ...
Patrick's user avatar
  • 331
13 votes
2 answers
2k 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: ...
eanmos's user avatar
  • 405
12 votes
1 answer
746 views

Java Spring Example Web API

I'd like to get some feedback on an example web API I've put together. It's mavenized and available on GitHub here. Setup The only thing you'd have to change to run this locally is line 31 in src/main/...
Kevin Workman's user avatar
11 votes
1 answer
814 views

Handling Java instant Ajax request/respond with Angular

I am trying to build a food search app. I am using Angular and Spring. I am currently using the yelp API, but it's done on the Java side. I think what I have achieved is really bad design. It works, ...
OPK's user avatar
  • 285
10 votes
2 answers
41k views

Preventing XSS attacks in a Spring MVC application controller

One of the URL in my application is vulnerable to XSS attack, so I am handling it in the below way. I created a util class: ...
OTUser's user avatar
  • 737
10 votes
2 answers
619 views

Super sophisticated game information web application

Considering I've got an exam on Spring tomorrow, I figured you could review a small example application I whipped together as preparation (and as such, I'd prefer the emphasis to be on Spring-related ...
Jeroen Vannevel's user avatar
10 votes
1 answer
6k views

Spring JWT authentication using cookies

I'm working on a experimental code which allows users to authorize using JWT's jjwt library. Here's what I have done so far on authentication and authorization flow....
benjamin c's user avatar
8 votes
2 answers
6k views

Spring password validator library

I recently got rejected at a job interview for submitting this: https://bitbucket.org/gnerr/password-validator The interviewer asked for a password validation library that was configurable via ...
user886596's user avatar
8 votes
2 answers
4k views

Registration, login and logout in a Grails application

I'm completely new to Groovy, but have many years of Java experience, and recently I have started working on a Grails application, currently it contains the following: User and Person domain classes ...
skiwi's user avatar
  • 10.7k
7 votes
2 answers
13k views

Spring autowiring in managed beans with support for serialization - is this safe?

Im trying to solve two problems I see with JSF2 and Spring. First @Autowired in @ManagedBean does not work Nor does ...
atamanroman's user avatar
7 votes
2 answers
146 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: ...
makiz1234's user avatar
7 votes
1 answer
6k views

Spring configuration without XML is this reality?

We're doing a website for Cardshifter, and now I've converted the plain html files and css into a Spring MVC web application. Here is the typical configuration classes that I used in most of the ...
Marc-Andre's user avatar
  • 6,701
6 votes
2 answers
15k views

Spring Boot RESTful service

I have developed this restful service using spring boot. Please look at the code if there is something to change to be more consistently. Resource ...
cool's user avatar
  • 63
6 votes
1 answer
472 views

Circular dependencies between immutable objects; the Freeze Pattern

Generally, I structure small threadsafe immutable objects like this: ...
corykendall's user avatar
6 votes
1 answer
149 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 ...
Marc's user avatar
  • 5,532
6 votes
0 answers
2k views

Implement two level caching using spring's cache abstraction Cache and CacheManager

Details about spring's caching framework are here. When I was reading this link, I thought the composite cache mentioned there was one that used levels of caching based on the order given to the ...
shrewquest's user avatar
5 votes
3 answers
3k 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 ...
Mohammad Javed's user avatar
5 votes
2 answers
1k views

Logging a message and the stack trace of caught exceptions

Using Spring's JdbcTemplate to load a specific object by ID if exists, I have this code: ...
janos's user avatar
  • 111k
5 votes
1 answer
6k views

Handling an invalid SQL query exception

This is my DAO object that takes the Cypher query as a string, and returns a JSON representation of the graph it returns. Because it's using a Spring JdbcTemplate ...
dwjohnston's user avatar
  • 1,308
5 votes
2 answers
1k views

Google Maps API with Jackson Parser

I am working on the Google Maps API, doing a reverse geocoding with the following code snippet. What I am using are: Spring Jackson Parser Google Maps API It is working fine but it gives results a ...
Shaun 's user avatar
  • 51
5 votes
1 answer
242 views

Bot-like Spring Java service for checking advertisements

I am in the middle of developing a Spring Boot application, which has a service acting like a bot. advertisementService.update(Advertisement ad) is a method which ...
gadomsky's user avatar
5 votes
1 answer
4k views

Create better Base DAO class

I created a DAO class which is base class for all other DAO classes. I use Spring Framework 4 and Hibernate 4. Question: Is there anything that could be done better? ...
user avatar
5 votes
1 answer
4k views

Custom ResponseModel for Spring Controller - ResponseEntity<?>

I created a custom responseModel to have a standard json responseModel for some of my different RestController. Superclass TransactionResponseModel: ...
Patrick's user avatar
  • 131
5 votes
2 answers
2k views

Authentication via LDAP and authorization via JDBC

I have a custom AuthenticationProvider for getting authentication via LDAP and authorization via JDBC. It's running but I think it's not the best way. My custom ...
BokC's user avatar
  • 151
5 votes
1 answer
267 views

JMS configuration -- client exclusive messages

I am SURE this is somehow easy but reading the docs isn't bringing it to light. The problem: I am trying to setup a JMS message listener and what I need is for the first client to have exclusive ...
Christian Bongiorno's user avatar
5 votes
0 answers
1k 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 ...
Georgii Lvov's user avatar
4 votes
3 answers
372 views

Java 8 use of optional

I have two methods I'd like to improve using optional and any other tool, ...
valik's user avatar
  • 141
4 votes
2 answers
256 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 ...
user2094257's user avatar
4 votes
1 answer
2k 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 ...
Dev_Joshi's user avatar
4 votes
2 answers
6k views

Getting products by category, price, etc

I have the following concerns: Is Set a good choice for getting products? What are drawbacks of Set for this purpose? Is it ...
rigby's user avatar
  • 255
4 votes
2 answers
817 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 ...
MetaCoder's user avatar
  • 153
4 votes
1 answer
1k views

Static method to get user ID

I have a method which extracts the logged-in user details from a SpringSecurityContext object. I have read that only utility methods (which does certain ...
Programmer's user avatar
4 votes
2 answers
80 views

Choosing Between Field Injections and Constructor Injections for Modular Java Applications with Spring Boot

I'm six months into a Java training program and have developed a Spring Boot application, adhering to Java's separation of concerns principle. I've organized my application with distinct sections for ...
Kerem Tazedal's user avatar
4 votes
1 answer
72 views

FastAPI Class based Design

I am new to the FastApi world. Can somebody review my below Fast API design? It is working but doesn't follow ...
garg10may's user avatar
  • 244
4 votes
1 answer
190 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 ...
P_user526's user avatar
4 votes
1 answer
30k 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 ...
forhadmethun's user avatar
4 votes
2 answers
597 views

Rest Controller in Spring Boot for Rock Paper Scissors REST API

I have created a Spring Boot Microservice for playing Rock Paper Scissrors. I have tried to follow best practices, but still would appreciate some critique on my code. Thanks. ...
GauravEdekar's user avatar
4 votes
1 answer
155 views

Code for my first crud app

I would like to ask more experienced developers to review my code, it's my first app, self-made, I know there is a lot to improve, it would be great if you could just point the main errors. I'm ...
filemonczyk's user avatar
4 votes
2 answers
260 views

Property file loader

I have the following code: ...
Eugene Ustimenko's user avatar
4 votes
1 answer
2k views

Property Change Listener for Entity Management

I would like to know if the solution I came up with for managing relationships between entities is sensible. Guys in my team feel it is transparent, but maybe I'm missing a pitfall somewhere? ...
xelamitchell's user avatar
4 votes
1 answer
107 views

Spring REST Endpoint for Saving a User Inquiry

Here's a piece of code from codebase I maintain/contribute to. It is a Spring REST controller, which exposes an endpoint to create user question. The question consists of title, description and ...
Sergey's user avatar
  • 541
4 votes
1 answer
372 views

Avoiding using strings when using Spring.Net by incorporating instantiation in class

Totally new to MVP and Spring, and I have what seems to be typical MVP application that uses Spring, where the presenter is instantiated like: ...
jmoreno's user avatar
  • 1,417
4 votes
1 answer
1k views

Spring Boot Websocket STOMP Crud

I have a personal project that runs the backend under spring boot that implements websocket for real-time functionality and I apply it to a crud operations. Although the code is working and work as ...
Ricardo Raz's user avatar
4 votes
1 answer
522 views

User registration - Controller, service and repository layers in Spring framework

I'm writting a registration feature currently and I I'm confused how to divide logic between layers. Can you review this code and tell if it's good way to do? In try-catch block I publish event to ...
Aro400's user avatar
  • 43
4 votes
1 answer
2k views

REST API that allows creating/removing users, CRUD ToDo tasks

My project is supposed to be used as back-end for a simple to-do web app that lets you create an account, add, edit, complete, and delete todos. It could be used with some front end consumer like ...
doublemc's user avatar
  • 285
4 votes
0 answers
3k 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 ...
Patrick's user avatar
  • 331
3 votes
2 answers
5k views

DAOs for Person, Employee, Staff, etc

I have an abstract PersonDao class, extended by several other DAO classes, for example EmployeeDao, ...
janos's user avatar
  • 111k
3 votes
1 answer
425 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: ...
Matley's user avatar
  • 133
3 votes
1 answer
6k views

Is my implementation of a simple CRUD service with Spring WebFlux correct?

I am implementing a simple Movie based CRUD API using Spring WebFlux and Reactive Spring Data MongoDB. I want to make sure that my implementation is correct and that I am properly using Flux and Mono ...
Son Goku's user avatar

1
2 3 4 5