Questions tagged [spring]
Spring is a module based open source framework to build robust Java / Java EE applications.
310 questions
-2
votes
1
answer
777
views
How to serve the front-end in a Spring microservice architecture?
I want to create the following distributed system: Spring back-end microservices containing the domain logic, a UAA (authentication) service, a Eureka service registry/discovery, a Spring Cloud Config ...
1
vote
0
answers
733
views
Performance impact of JPARepository save() on a large database table with index
We have a few tables with a large amount of data and with indexes on those tables to help in faster retrieval.
We are also using Spring Data JPA JpaRepository for adding data to those tables using the ...
0
votes
0
answers
78
views
Two Web clients and Java server (HTTP and Websockets)
I have 3 software components of a Web Application:
1. JS-client application 1 (JSApp1)
2. Java Spring (REST and Websockets) server app (SRV)
3. JS-client application 2 (JSApp2)
My current task is to ...
0
votes
2
answers
3k
views
Using Spring Boot's @ConfigurationProperties without violating Law of Demeter
My apps commonly have one or more prop holders. These holders contain config data used in the app such as:
@Component
@ConfigurationProperties(prefix="app.orders")
@Data //lombok
public class ...
2
votes
1
answer
2k
views
Handling an empty path variable request
I have a scenario where I can take a student Id as input via a part variable and return some data back as JSON objects where JavaScript handles the response as a part of AJAX call.
Suppose the method ...
4
votes
1
answer
451
views
Java inheritance error handling scenario
I looked multiple places for some advice on how to solve this before asking this question, but I couldn't find something similar to this.
So I have the following scenario in Java Spring Integration
...
0
votes
1
answer
149
views
Should I postfix application.yml?
My project structure (Spring / maven):
src / main / resources / application.yml
src / test / resources / application.yml
This is working well (when I launch test, it takes the test application.yml).
...
-1
votes
2
answers
204
views
Dealing with data download which could take days to download
I have a situation on the front end where a user clicks on “Download” button and the query behind the scenes is going to take over a day. I have a Spring boot web app running as far as web services ...
0
votes
1
answer
1k
views
Java Design Pattern to Use for switching between 2 different endpoints
I have a legacy service that is running on-prem and have built a new service that runs on cloud which provides the same functionality. I have another java (spring) service which consumes the on-prem ...
1
vote
2
answers
4k
views
Streaming file content efficiently without risking resource leaks
I have to rectifiy an application that basically serves content by using two REST endpoints. Both endpoints transfer files to the browser, one endpoint does so by providing the file in binary format, ...
3
votes
2
answers
5k
views
How do entities, DTO, DOA work together and what’s their role within a system?
Most of my work is written in Java using Spring Boot. In a recent project my entities contained no business logic, Spring Data was used to handle repositories and I have service classes that ...
1
vote
0
answers
161
views
Is separating a Spring Boot REST API into interface and implementation a good practice?
I "herited" a lot of Spring Boot code which is basically an asortment of REST Webservices.
All those webservices are separated into an interface and an implementation and I find it hard get a grasp of ...
5
votes
2
answers
16k
views
How to deal with large data in Websocket message?
I wrote a websocket server in Spring Boot and a client in Javascript. These work fine. I also wrote a second client in Java. When this one attempts to handle a frame after connecting to the host, I ...
0
votes
1
answer
1k
views
Best approach for web service that calls other web services
The scenario is:
client makes request to server A
Server A makes potentially multiple requests to server B. Edit to clarify, server A makes the requests concurrently using Futures.
Server A blocks ...
0
votes
1
answer
201
views
Best way to handle environment specif fields in Hibernate
We have one microservice that will be deployed on two different environments(A and B). There are some common fields and also some are specific to the environment.
Example:
SomeEntity for environment ...
1
vote
1
answer
1k
views
Where to store static contents
Recently I am developing a new feature for my web application that must be Release Independent.
The feature requires to show some predefined data. Those data will rarely be changed or updated. Here ...
1
vote
0
answers
848
views
How to make rest api end points in swagger UI pre authenticated in Spring BOOT [closed]
I have written a spring boot rest API application with OAuth.I have integrated swagger UI for API documentation. I want the API endpoints on swagger UI to be accessible without an access token.
This ...
4
votes
3
answers
2k
views
HATEOAS APIs and front end development
We are developing a tool from scratch based on a Spring backend and VueJs frontend. I am primarily working on the backend and came to know about the HATEOAS principle of developing REST APIs and ...
2
votes
2
answers
2k
views
Returning JPA Entities in Rest Api's?
Recently Ive seen so many devs working with the stack Spring/JPA and returning all these JPA entities on their rest controllers.
In my opinion it's a BAD PRACTICE for several reason such: ...
1
vote
2
answers
1k
views
Is it okay to put all your error handling on facade layer?
I am doing a Java Spring-Boot backend project and I am implementing a controller-facade-service pattern on my structure.
So is it best to put all my error handling on the facade layer, while the ...
53
votes
1
answer
71k
views
What is the use of DTO instead of Entity?
I am working on RCP application, I'm new to this application.
Spring beans are used to write business logic to save/fetch entities.
But, instead of sending entities directly to client we are ...
1
vote
0
answers
908
views
Putting the rowmapper inside the domain class
Normally in java the RowMapper is placed in its own class.
Instead, what about this design, putting the RowMapper inside each domain object, and giving all of them a consistent name:
public class ...
1
vote
0
answers
588
views
Maven plugin to operate at parent and child module levels?
I have a large multi-module java/maven application where each child module is it's own java application and the root parent pom defines the standard dependencies
pom.xml - parent pom
- child1/pom.xml ...
5
votes
1
answer
753
views
IEC 62304, Are Software Frameworks (Spring/JEE/Angular/React) considered SOUP?
Im working on the implementation of an IEC 62304 compliant development process in our company and I have a question considering SOUP (Software of unknown Provenance).
Our goal is the develop a web ...
5
votes
3
answers
3k
views
Handling domain errors in the API
I'm working on building an API interface on-top of a domain-driven architecture.
The domain layer has a bunch of specific exception classes (i.e. NameIsRequiredException, CannotPublishDraftException, ...
2
votes
2
answers
2k
views
How to correctly split a monolith and rely on the same domain
Context
I'm developing a Spring Boot java application. Currently it is a monolith with the rest API and the front end (vaadin driven) in the same big project.
Although this is very easy to develop ...
-1
votes
1
answer
418
views
Given an implementation of a Service Layer and Repository layer, should you make tests of both?
Currently I have an entity called Product with the respective ProductRepository and ProductService.
For ProductService, I have tests for:
Read (Covering Create too)
Update
Delete
Besides achieving ...
9
votes
1
answer
14k
views
Data Objects for each layer(DTO vs Entity vs Response objects)
Let's say I'm building a Customer web application(in Spring Boot 2), which also exposes rest end points. I'm modeling my application into 3 layers.
a) UI - CustomerDTO
b) REST - ...
0
votes
2
answers
159
views
Spring application context - dependency chaos
I am new in a team working on a grown and complex Spring MVC application. The application context is widely wired using @Autowire annotated constructors. This seems to be the main reason for the issue ...
2
votes
1
answer
386
views
What is the better place to create the Binding and Queue on RPC communication: Consumer or Producer?
I was talking with part of my team about the responsibility for who own the Binding and Queue creation. We are using Spring framework.
In async communication they agree that the responsability to ...
0
votes
2
answers
424
views
How to not leak the auditing information to the business layer
From a REST API, we write to the database. We want to store who was the person that triggered this change. We have this information at the controller layer. The saving happens at the repository layer (...
0
votes
2
answers
291
views
Design public API - String or generic type?
My team needs to design an API which sends objects to a queue in the cloud and retrieves objects from it. The data is inserted into the queue as byte[].
We have 2 ideas until now which I would love ...
0
votes
2
answers
251
views
From a mobile application client to API/microservices
Let's say I have a mobile client for answering questions and then purchasing a widget. For example, I might have 10 screens from my UI with about 8 questions per screen. Imagine there is a screen ...
18
votes
3
answers
18k
views
Java: Is it okay to abuse Spring beans (@Component) rather than use static final utility classes?
I'm torn between using DI and static utility classes on my code.
I currently created a DateUtil static class that is only meant to be accessed statically. This class is responsible for just creating ...
0
votes
2
answers
148
views
Should I create a Repository Container to get my repositories?
@Component
public class RepositoryContainer {
@Autowired
public CommentRepository commentRepository;
@Autowired
public ItemRepository itemRepository;
@Autowired
public ...
2
votes
2
answers
6k
views
Maintaining stateful information in REST API
I am developing a REST API which accepts JSON using Spring Boot. I use Spring Security for authentication. I have a use case where I have two services, one to test connection to a 3rd party system and ...
3
votes
1
answer
21k
views
Project Structure of Domain Driven Design in maven Java Spring-Boot [closed]
My team is in dilemma, we have an existing maven spring-boot Java8 project with following onion architechture.
controller --> service --> dao --> jpa repositories
...
8
votes
2
answers
40k
views
Are Spring beans declared as static a poor design choice?
The question is pretty straightforward, I'll try to explain why I want some explanations.
(All of this is my 1½-year junior Java developer opinion, which may be more than incomplete. Which is why I ...
2
votes
2
answers
2k
views
Ways to store objects, inherited from one superclass in a database
For my personal project I need to store 2D shapes in a Postgres database. For example Circle, Pentagon, Rectangle and so on. At first I've done it like so: all shapes are inherited from an abstract ...
0
votes
1
answer
785
views
In implementing layered API architecture with Spring MVC Boot, how to connect to various endpoints
If you want to implement a layered API design for example, you may have one API layer that represents the application layer. And I assume that the application layer is represented by an endpoint and ...
2
votes
3
answers
548
views
IOC container & accessing Implementation from the container
Background
As mentioned in this article,
Inversion of Control can be achieved through various mechanisms such as: Strategy design pattern, Service Locator pattern(SLP), Factory pattern, and ...
3
votes
1
answer
2k
views
Creating interface fields to inject vs Objects?
In the tutorial I'm doing it uses interfaces to inject things, for example it uses a IHotDrink interface, then creates a Tea class that implements IHotDrink. It then has a third class called ...
7
votes
1
answer
4k
views
Should DTO have same structure as payload?
I have a usecase where I am supposed to store entire payload from a third party API in addition to the DTO, say XYZDto, its translated to.
There are two ways to achieve that -
Translate the payload ...
19
votes
3
answers
8k
views
DDD - Is anemic domain model an antipattern? Shoud we be using rich domain models? [closed]
Anemic domain model was criticized a long time ago by Evans and Fowler, since apparently it goes against object oriented principles, etc. The DDD community is clearly aligned with this statements.
...
1
vote
1
answer
5k
views
Does Web Socket block thread while keeping connection as regular http connection does?
Let's take Spring web socket (with tomcat) for example.
Does Web Socket blocks thread while keeping the connection between server and client? (For example, connection can last 2-3 hours).
(
Does web ...
-1
votes
1
answer
811
views
IOC principle - Servlet container implementation
IOC principle can be implemented, using either:
Dependency Injection
Service locator pattern
This article also supports these two approaches for implementing IOC principle.
Spring IOC container is ...
1
vote
0
answers
2k
views
Using import.sql vs persisting JPA entities
In Hibernate ORM & Spring Boot, during the SessionFactory creation, SQL DML statements can be executed to create tables and/or insert data via files such as import.sql defined in the javax....
5
votes
0
answers
2k
views
Understanding the data flow in Spring REST layered architecture
I am new to Spring as well as layered architecture. So am a bit confused as how data flows among the different layers.
What so far I have understood is:
Layers:
Controller (which accepts requests)
...
2
votes
1
answer
7k
views
How to represent and validate website URLs for a JPA entity
I have an application that will allow the user to enter and store (in a DB) a website URL for a company. The only requirement (as of now) beyond entry of the website URL is to validate that the URL is ...
-1
votes
1
answer
3k
views
Spring Exception Handling. Custom exception per Http status?
I'm just designing the exception handling for the REST interface on our Spring server.
As we will have multiple REST controllers, a central exception handling is desired. Spring offers the solution ...