Questions tagged [spring]

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

Filter by
Sorted by
Tagged with
262 votes
7 answers
296k views

What does the Spring framework do? Should I use it? Why or why not?

So, I'm starting a brand-new project in Java, and am considering using Spring. Why am I considering Spring? Because lots of people tell me I should use Spring! Seriously, any time I've tried to get ...
  • 3,219
57 votes
4 answers
11k views

Are there exceptional cases where we can accept duplicate code?

I'm working on a software project where we have to build three APIs. One for the home banking channel, one for the agency channel and a third for the mobile channel. The agency API is the most ...
53 votes
4 answers
17k views

Why do we need frameworks for dependency injection? [closed]

I've been reading up more on the Inversion of Control principle and Dependency Injection as an implementation of it and am pretty sure I understand it. It seems to be basically saying 'don't declare ...
  • 641
47 votes
1 answer
59k 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 ...
44 votes
6 answers
39k views

Why not Spring framework? [duplicate]

Are there any disadvantages in tying my application to Spring framework? I'm not talking about bugs or issues like that, if any. I'm talking about strategic, architectural things that will influence ...
  • 551
41 votes
6 answers
64k views

Which classes should be autowired by Spring (when to use dependency injection)?

I have been using Dependency Injection in Spring for some time now, and I understand how it works and what are some pros and cons of using it. However, when I'm creating a new class I often wonder - ...
  • 527
30 votes
3 answers
38k views

Should service layer catch all dao exceptions and wrap them as service exceptions?

I have three layer Spring web app: dao, service and controllers. A controller never calls directly the dao, it does it through the service layer. Right now, most of the time if there is dao exception ...
  • 443
30 votes
6 answers
33k views

In which layer should validation be located?

I'm creating a Rest API using Spring Boot and I am using Hibernate Validation to validate request inputs. But I also need other kinds of validation, for example when update data needs to checked, if ...
  • 401
22 votes
3 answers
8k views

API Gateway (REST) + Event-Driven Microservices

I have a bunch of microservices whose functionality I expose through a REST API according to the API Gateway pattern. As these microservices are Spring Boot applications, I am using Spring AMQP to ...
19 votes
5 answers
63k views

Do I need to know servlets and JSP to learn spring or hibernate or any other java web frameworks? [closed]

I've been asking a lot of people where to start learning java web development, I already know core java (Threading,Generics,Collections, a little experience with (JDBC)) but I do not know JSPs and ...
  • 961
18 votes
1 answer
9k views

Java application structure: Horizontal vs vertical split

Having a bit of a debate about the starting project structure (using Maven/Eclipse) for a big Java application. Option 1: entities (i.e. the whole database using Hibernate classes-first) services (i....
18 votes
2 answers
67k views

Where to put Spring configuration file?

I want to integrate Spring framework in my project especially into server side. So, I don't want to put it within WEB-INF folder of war file. Should I put an applicationContext.xml it into each ...
  • 3,798
16 votes
4 answers
18k views

When not to use Spring to instantiate a bean?

I am trying to understand what would be the correct usage of Spring. Not syntactically, but in term of its purpose. If one is using Spring, then should Spring code replace all bean instantiation code? ...
  • 345
16 votes
1 answer
5k views

Why is it such a bad idea to share an interface between server and client?

I was reading the Spring Cloud Netflix documentation when I found out about a way to share an interface between an HTTP server and its client. They use this example for microservices, although there's ...
  • 263
15 votes
3 answers
8k views

“Depend on abstractions, not on concretions” what is the exact meaning of this term

I was reading SOLID principles on a website, in which for D - Dependency Inversion Principle it says: “Depend on abstractions, not on concretions” In other words. we should design our software in ...
  • 265
15 votes
2 answers
9k views

Microservice architecture shared domain models

Lets assume that we have a Spring Boot application that uses microservices architecture. Each of the services has its own domain models, but each service must reference a User domain object. What ...
15 votes
3 answers
6k 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. ...
14 votes
3 answers
11k 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 ...
  • 761
13 votes
2 answers
20k views

Structure of RESTful Service with Java Spring for Beginner

I am relatively new in terms of Java web development skills. I have a project that I think would make a good candidate for a RESTful service from what little I understand about APIs. I'm trying to get ...
  • 329
13 votes
3 answers
6k views

Multiple Oauth2 access tokens

I have an API that uses oAuth2 and my own mobile apps that use this API as their backend. Since users can be logged on via multiple devices (i.e iPhone, iPad, android tablet or android phone) at the ...
  • 279
12 votes
3 answers
32k views

How to manage 2 DAO methods in a single transaction?

In an interview someone asked me : How do we manage 2 transactional/dao methods in a single transaction. Desired capabilities: If anyone of them fails we need to rollback both methods. Both of the ...
12 votes
2 answers
15k views

Is Spring + Hibernate prefered instead of EJB 3?

It is my perception that whenever new JEE projects start (where these technologies would be applicable), people prefer to use a combination of Spring + Hibernate instead of EJB 3. It seems junior ...
  • 2,309
11 votes
1 answer
424 views

REST service as an application server for 2000+ client machines. Is it a good idea?

We will be building a system with the UI in javaFx that will be deployed to 2000+ machines (minimum is 2000, but it will be more - can reach 5000 machines). For other reasons/limitations it must be ...
10 votes
1 answer
13k views

Separating front end from back end - Tomcat

I'm currently working with a company that uses Java / Tomcat / Spring for the back end of our web applications. As a front-end developer, I'm feeling more and more strongly that the back end should be ...
10 votes
2 answers
10k views

Client-side Rendering vs JSP's for Spring MVC Front End Dev

Firstly, a note on the app I'm about to discuss: It's quite large, on the order of magnitude of a service app like Airbnb -- i.e., it's not just a static web page, it is a full web application. It's ...
  • 111
10 votes
1 answer
2k views

How to migrate existing legacy webapp to use OAuth2

I currently have a 15 year old legacy monolithic webapp with close to 1 million users, using a home-grown authorization & authentication system: JAAS, user names & pwds store in a DB with ...
  • 1,219
9 votes
1 answer
12k 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 - ...
  • 103
9 votes
4 answers
4k views

Spring - Confusion over configuration?

Somewhere I read Spring offers convenience over configuration. But Spring folks are bringing in so much changes over the configuration , that I am now really getting confused to use the xml ...
user avatar
9 votes
2 answers
582 views

Effectively tracking changes to configuration from dev to prod

This question takes a Spring Boot service as an example, but it could be any technology. Assuming the following: Environments (dev/QA/prod) are owned by different teams. This means dev must not have ...
9 votes
2 answers
692 views

Gradually move codebase to dependency injection container

I have a large codebase with a lot of "anti-pattern" singletons, utility classes with static methods and classes creating their own dependencies using new keyword. It makes a code very difficult to ...
  • 217
9 votes
2 answers
2k views

Synchronisation with offline system

I'm designing a system from which I will synchronise business data from the mobile device (that have an embedded application) that generates data and sends it back to the server. Each line ...
  • 3,456
8 votes
1 answer
6k views

How to choose between lightweight or heavyweight framework for web application [closed]

In my current role as a software developer in a Java/Spring/Hibernate/JSF shop, I am sometimes asked to develop large-scale web apps with many interfacing systems and/or large databases as well as ...
  • 3,507
7 votes
3 answers
14k views

How significant are Spring and Hibernate in software development? [closed]

I am a software professional with about 1.6 years of experience in Java. Due to personal reasons, I had to quit my job, and now after 5 to 6 months, I am about start my career again. I am planning to ...
7 votes
1 answer
1k views

Why were annotations introduced in Spring and Hibernate?

I would like to know why were annotations introduced in Spring and Hibernate? For earlier versions of both the frameworks book authors were saying that if we keep configuration in xml files then it ...
7 votes
2 answers
6k views

How can I plugin new JARs implementing an interface dynamically?

Quick background: I am working on developing an interface that will be implemented by myself and other developers. This interface will allow users to "plugin" new functional code into a system for ...
  • 233
7 votes
2 answers
5k views

Why Java does not have a framework like Rails? [closed]

I am a Ruby on Rails developer and I like its simplicity and rapidness. On the other hand we need to use Java for some projects that we develop for our clients. My question is why (pure) Java does ...
  • 187
7 votes
1 answer
2k views

What the fastest way to pass large data between JVMs?

I have 2 JVMs on the same machine that I want to pass about 1Mb of (serializable) data between ideally in under 5 ms. Under load, using HTTP to localhost takes about 70ms average. I tried hazelcast, ...
  • 1,866
7 votes
1 answer
2k views

Spring Batch + Web Scraping

I need to develop a batch processing that will be executed every day. These are the steps: Read each line of a database table that contains a URL (SQLite) Extract some data, say Users, from that ...
  • 717
7 votes
4 answers
8k views

Programmatically extending Hibernate table/entity definitions in Spring, how?

I would like to know if there is a way —maybe with AOP— to extend table/entity definitions so that I can add functionality across the board that requires persistence. Let me explain what I want to do ...
  • 13.9k
7 votes
1 answer
34k views

Difference between spring setter and interface injection?

I know how constructor and setter injection works in spring. Normally I use interfaces instead of classes to inject beans using setter and I consider it as interface injection, but in case of ...
6 votes
2 answers
5k views

What is a transaction?

When reading Spring tutorials I'm quite often coming across the @Transactional annotation. When I google it, I get documentation that says things like: Comprehensive transaction support is among ...
  • 2,483
6 votes
3 answers
22k views

Difference between an architecture and a framework [closed]

A terminology question appeared when I was comparing EJB 3 and Spring. Wikipedia says that Enterprise JavaBeans (EJB) is a managed, server-side component architecture for modular construction of ...
6 votes
1 answer
28k 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 ...
6 votes
1 answer
8k views

Usage - Factory Pattern vs Dependency Injection [closed]

Okay, this question is not on which is better. It is more about when to use Dependency Injection vs Factory. I have done a bit of research and it goes like this. DIP: Provides loose coupling, ...
  • 411
6 votes
2 answers
16k views

Issues about static injection in Spring?

I use spring-boot with spring xml in my project. I wrapper the DAOs in a DataAccessService class to serve as a DB service layer, both the service and the DAOs are injected in spring xml and used by ...
  • 196
6 votes
2 answers
6k views

Is it correct to use PUT with multipart content?

We are using Spring and want to implement a REST with a "override file" call so we think using PUT verb with a multipart body only to find that Spring don't accept it. My question is it can't be done ...
  • 313
6 votes
1 answer
2k 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 ...
6 votes
1 answer
3k views

Is it a good idea to use a Spring MVC as an Frontend of a Microservice Architecture?

My microservice prototype currently has a Spring boot MVC application as its front-end. The application renders the View completely in the backend. It makes rest calls to other microservices like ...
  • 199
6 votes
1 answer
787 views

Best practice for ensuring name uniqueness/correctness in message queues in a microservice architecture/distributed system

I was wondering what a good solution would be for ensuring that queue-names are entered correctly and are only used by the correct applications in a large system which uses message queues to exchange ...
  • 135
6 votes
1 answer
1k views

Attachment handling for web application with Jackrabbit

I need to manage attachments on my Spring web application and I thought to use an open source repository. My app it's a job approval system using J2EE / SPRING 3 Framework and Postgress DB to allow ...

1
2 3 4 5 6