Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [spring]

Spring is a module based open source framework to build robust Java / Java EE applications.

0
votes
0answers
19 views

JPA - Create an entity when data is not used beyond query?

My application queries a third party database with read only access. I need to get cars built after certain date and have a history of being traded and sent to a dealer. The relationship is a car has ...
3
votes
1answer
108 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
1answer
30 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
2answers
122 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
1answer
103 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 ...
0
votes
2answers
192 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
2answers
107 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
0answers
42 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 ...
1
vote
0answers
321 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
1answer
98 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
1answer
27 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 ...
0
votes
1answer
55 views

Spring Boot - Extending 'Base' or 'Common' JARs

Here is the situation at work: We have a 'framework/patchwork' team that is responsible for setting up . However it is hardly consistent. Recently, we received implementation for work that did not ...
1
vote
1answer
120 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
0answers
230 views

How to make rest api end points in swagger UI pre authenticated in Spring BOOT

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. Please ...
1
vote
3answers
285 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 ...
1
vote
2answers
134 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
2answers
257 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 ...
1
vote
1answer
2k views

what is the use of DTO instead of Entity

I am working on RCP application, I am 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
0answers
85 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
0answers
189 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 ...
3
votes
1answer
131 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 ...
3
votes
3answers
135 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, ...
1
vote
2answers
176 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 ...
0
votes
0answers
899 views

Repository vs. DAO (again)

In general this back-story does not matter but just to explain the code below: The server handles users and user groups. User groups are able to "discover" places - at this point in time these places ...
0
votes
1answer
191 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 ...
1
vote
1answer
3k 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. 1) a) UI - CustomerDTO b) REST - ...
0
votes
2answers
81 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 ...
0
votes
0answers
169 views

Scoped beans as dependencies - Use proxy or make it dependent/prototype scoped?

Regarding overall performance, when used as a dependency of a higher scoped bean, is it better to downgrade a bean scope to prototype or dependent instead of using proxies? Consider a scenario where ...
2
votes
1answer
174 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
2answers
150 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
2answers
223 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
2answers
77 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 ...
4
votes
2answers
1k 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
2answers
110 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
2answers
1k 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 ...
2
votes
1answer
5k 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 ...
3
votes
1answer
4k 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 explainations. (All of this is my 1½-year junior Java developer opinion, which may be more than incomplete. Which is why I ...
0
votes
2answers
359 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
0answers
46 views

Best way to implement a unified database of several shared database

i'm implementing a sync service that store the database of a device into another. Right now, the source system use a very simple table schema: The PK is a varchar(40) always. To do the sync, I ...
0
votes
1answer
511 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 ...
3
votes
3answers
319 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 ...
2
votes
1answer
300 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 ...
6
votes
1answer
367 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 ...
7
votes
3answers
2k 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
votes
1answer
1k 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 ...
0
votes
1answer
276 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
0answers
1k 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....
3
votes
0answers
852 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) ...
0
votes
1answer
1k 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
1answer
2k 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 ...