Questions tagged [spring-boot]

92 questions
14
votes
2 answers

Should I validate dtos or entities?

I want to place validation in one layer for the reason of simple code maintenance. I was thinking of entity validation, cause this protects directly database. Am I right, or should I add validation also on dto level? I would be happy, if someone…
Bartek
  • 251
  • 1
  • 2
  • 5
7
votes
3 answers

Is it a good idea to share repositories across microservices in Spring Boot Application?

We are migrating a desktop application into web based Spring Boot micro services application with a client imposed mandate of using their existing MySQL database, so all micro services share a common database. Since its a SQL database we chose…
6
votes
5 answers

What to cover with integration tests?

I'm working on adding unit/integration tests to an existing project (Java/Spring Boot) and I've been investigating on how they are "separated" in order to cover the test cases and how to focus each type of tests based on what they are written…
5
votes
3 answers

Spring Boot - What is the purpose of Autowired Constructors?

I’ve been developing in Spring Boot for just over a year but have yet to understand the benefits of using an Autowired constructor and I was wondering if someone could explain this to me and what would be considered best practice. Let’s say I have a…
4
votes
4 answers

What are the advantages of externalizing application configurations?

I was learning about micro services with spring boot and came across spring cloud config server which is used to exernalise application configuration.The advantage it state is that one can change the configuration without redeploying the application…
Arjun
  • 149
3
votes
2 answers

Populating Cache in microservices

These days I was asked by our technological leader to populate a cache. The exact nature of the request impacts a back-end (BE) system that operates on a database through a client library. The BE is a Java Spring Boot application and the client…
Chaos
  • 147
3
votes
2 answers

Can DTO have helper method that operates on DTO fields?

I wonder where to add method that reads my dto WindowDto.getPath().getPoints() and based on this collections returns some value (that value will be needed in some different srevices in my app): public class WindowDto{ …
Matelutex
  • 141
3
votes
2 answers

Spring Boot REST Java Microservice: Why Use Maven Submodules?

I have seen a project which uses Maven submodules. The project itself is a spring boot application that exposes Restful API endpoints for a microservice ex: Customer Service (getCustomers, createCustomers etc); consisting of standard model classes,…
2
votes
3 answers

Is there a way to avoid a lot of calls to other microservices from one single service request?

I'm developing a Microservices Web Chat Application using Spring boot and Websockets. Right now my concern is the following: it seems like each one of my microservices need to make a lot of calls to another services for just a requests what makes…
2
votes
3 answers

How can I avoid duplicate annotations when validating both Entity and DTOs?

I am using the Spring Boot framework to create a RESTFUL API and I need a way to avoid the duplication of validation rules when using multiple DTOs as request/response objects for my endpoints. Using the following example for the…
2
votes
3 answers

What we called this design pattern and it is same as strategy pattern?

abstract class BaseService { public void doSomething(); } class AService extends BaseService { public void doSomething(){ // Do something... } } class BService extends BaseService { public void doSomething(){ // Do something... …
2
votes
2 answers

Is it a good practice to Mock entity manager in spring boot unit testing

I currently design an API using spring boot. In my service layer, I use Entity Manager for accessing the database. I have provided a method in my service layer below as an example. public Object getFirstReturnDate(Long vehicle_id, LocalDateTime…
2
votes
1 answer

Implementing transactional entity lockouts with Spring and JPA

Spring Boot/Java 8/MySQL here. I have a widgets table in my MySQL DB that is modeled by a JPA entity like so: @Entity @Table(name = "widgets") @Data public class Widget { @Column(name = "widget_property") private String property; //…
2
votes
4 answers

How to compare passwords which is stored in DB in encrypted form in secure way?

Recently In an interview I was asked this question - Question- If are storing passwords in encrypted format in DB and in future when user login into our website how will we perform authentication? Me:-we will first first encrypt the password using…
Loren
  • 147
2
votes
1 answer

Refresh tokens by example using Angular and Spring Boot

I am designing out an app that would have an Angular frontend and Spring Boot (Java) backend. I was considering (but not married to) the prospect of JWT-based authentication: User logs in with username and password and submits a form; this form…
1
2 3 4 5 6 7