Questions tagged [spring-boot]

78 questions
13
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
  • 241
  • 1
  • 2
  • 5
6
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…
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…
Space Cadet
  • 153
  • 5
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{ …
Matley
  • 141
  • 5
2
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
  • 129
  • 4
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
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
  • 4
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…
2
votes
3 answers

A question on microservice boundaries around monitoring

I have a microservice, lets call it microservice A. It talks to another microservice's REST endpoint, lets call that one microservice B. I'm monitoring the health of microservice A using the Springboot actuator health endpoint. I've had a code…
Johnny Alpha
  • 510
  • 1
  • 4
  • 7
2
votes
0 answers

Send push notifications from ActiveMQ

I am trying to figure out how to send push notifications back to the client in the following ActiveMQ scenario: I have a spring boot web application #1 deployed on tomcat on RHEL server. From the user interface (this consists of…
Tan
  • 151
  • 6
2
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,…
user1955934
  • 121
  • 2
1
vote
1 answer

The recommended Spring Boot project structure leads to repetitive code

When implementing projects in Spring Boot (especially CRUD applications), I often find myself writing a lot of repetitive code that just calls functions and services from lower layers. For example, when implementing a web service with some REST API,…
Win32
  • 13
  • 2
1
vote
4 answers

Are static classes/methods good for pure business logic?

I have a service class that performs some operations. One of the operations is a piece of code long enough to warrant extracting to a new class and unit test it in isolation: @Service public class ItemFinalizer { private final ItemPublisher…
KidCrippler
  • 119
  • 4
1
vote
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…
1
vote
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; //…
1
2 3 4 5 6