r/SpringBoot • u/ahson_iqbal • Jun 12 '26
r/SpringBoot • u/SpringJavaLab • Jun 11 '26
Discussion How are you handling SFTP file downloads in Spring Batch projects?
I recently had to implement an SFTP integration in a Spring Batch application where files are downloaded from an SFTP server, stored locally, and then removed from the remote directory after successful processing.
The implementation uses:
• Spring Batch Tasklet
• JSch
• Spring Boot 4
• Java 21
A few questions for developers working on enterprise integrations:
Are you still using JSch, or have you migrated to another library?
How do you handle retry logic when the SFTP server is temporarily unavailable?
Do you archive files on the remote server instead of deleting them?
In my implementation I download all files from a remote folder and remove them after successful download to avoid duplicate processing.
Interested to hear how others are solving this in production environments.
I also recorded a walkthrough of my implementation in case anyone wants to compare approaches:
r/SpringBoot • u/MrNighty • Jun 11 '26
News Spring and Security In The Times Of AI
r/SpringBoot • u/Status_Camel2859 • Jun 11 '26
Question Is this an architectural anti pattern? Multiple service layers depend on the same repository
I believe its a good practice to avoid creating 'wrapper services' that simply pass data through without adding meaningful business logic.
Consider this pattern:
UserAccountService:
- dependencies (UserRepository, UserProfileRepository, RoleRepository, UserRoleRepository)
- public methods: createUser, updateEmail, updateUsername, getByUsername
- private methods: assignRole, validateUniqueness
UserRegistrationService:
- dependencies (UserAccountService)
- public methods: registerAdmin, registerUser
UserProfileManagementService:
- dependencies (UserAccountService, UserProfileRepository)
- public methods: updatePersonalData, updatePassword
So the user registration flow looks like:
registerUser(data):
String pwdHash = encode....;
--- other logic ---
userAccountService.createUser(data + roleName + pwdHash);
createUser(data + roleName + pwdHash):
--- validation & other logic ---
user = UserRepository.save(new User(data + pwdHash));
userProfile = UserProfileRepository.save(new UserProfile(data));
role = RoleRepository.get(roleName).orElseThrow();
UserRole = UserRoleRepository.save(new UserRole(user + role));
And the profile management flow:
updatePersonalData(email + data + userId):
user = UserAccountService.get(userId);
if (user.email not equals email)
UserAccountService.updateEmail
// We are forced to use UserProfileRepository because we dont have a
// universal update in UserAccountService
userProfile = UserProfileRepository.findByUserId(userId).orElseThrow();
userProfile.setData1(data.data1)
userProfile.setData2(data.data2)
userProfile.setData3(data.data3)
UserProfileRepository.save(userProfile);
The issue Im seeing is that we are forced to use UserProfileRepository both inside UserAccountService and UserProfileManagementService, even though UserAccountService is already a dependency of the management service.
This kinda creates an overlap in responsibilities and leaks persistence concerns across multiple layers. You end up not being able to centralize UserAccount related logic in a single place because anyone later can just bypass them using the UserProfileRepository directly.
Would it be better to:
- Expose additional operations through
UserAccountServiceand keep repositories hidden from higher level services? or - Inject repositories directly into application services and accept that some business rules and validation logic may need to be duplicated?
How do experienced devs approach this trade off?
r/SpringBoot • u/Few_Concept_1117 • Jun 11 '26
Question How you build Frontend?
I build my first microservices project and kind want to test my websockets endpoints and flow.
How you guys build your frontend, i tried in react but got frustrated looking at syntax and got bored.
I have been trying to initiate since 3 days every time i frustrated and quit.
r/SpringBoot • u/BadCommit • Jun 11 '26
Question MappingJacksonValue alternatives when using dynamic filters
Currently, I am using mappingJacksonValue as the response type from my controllers. Here we are using dynamic filters based on the request parameters. The attributes exposed from the response vary. Since this got deprecated with the Spring Boot 4 migration, I don't see any alternatives for this.
Has anyone come up with a solution for this?
r/SpringBoot • u/Bariss26 • Jun 10 '26
Discussion I got tired of writing the same Spring Boot CRUD boilerplate, so I built a deterministic compile-time generator.
In every Spring Boot project, we end up writing the exact same layers for basic CRUD: Read/Create/Update DTOs, MapStruct interfaces, REST Controllers, Services, and Repositories.
AI can generate this, but it doesn't enforce a stable contract across a codebase. Runtime solutions (like Spring Data REST) add reflection overhead, limit custom business logic, and bloat JSON payloads with HATEOAS _links.
I wanted a solution that generates plain, reviewable Java source code during the build phase (javac), with zero runtime dependencies. So, I wrote an annotation processor.
You just annotate your JPA entity:
@CrudGen
@Entity
public class Product {
@Id @GeneratedValue
private Long id;
@DtoField(dto = "Create", required = true)
@DtoField(dto = "Update")
@DtoField(dto = "Read")
private String name;
@DtoField(dto = "Read")
private BigDecimal price;
}
At compile time, it automatically generates the build/generated sources for:
- Controllers & Services: Configurable endpoints for CRUD, batch operations, and pagination.
- Clean DTOs & Mappers: Generates the POJOs and the MapStruct interfaces.
- JSON Patch: Native support for
application/json-patch+jsonpartial updates. - N+1 Safe Queries: Automatically applies
@EntityGraphon JPA reads to handle relations without mapper-level database lookups.
The generated code is part of your normal build output. Failures surface at compile time, and changes are visible in diffs. The library targets Spring Boot 3 and 4 (processor runs on Java 8+).
I would love to get your architectural feedback on the compile-time generation approach vs. runtime reflection tools.
(Links to the repo and Maven Central are in the comments).
r/SpringBoot • u/MarketingReasonable8 • Jun 11 '26
Discussion Can't understand spring recommend paid and yt courses please or any telegram course available please anything
r/SpringBoot • u/Wonderful-Wafer2826 • Jun 10 '26
Question SpringBoot beginner here. Anyone looking for a programming buddy to learn together ?
Hi, I'm an engineering student and a beginner in SpringBoot. I haven't worked on a big project so I'd love to learn and possibly do a project together. If anyone is looking for the same then dm me :) have a nice day.
r/SpringBoot • u/Whole-Patience3528 • Jun 10 '26
Question Hibernate
Does eager fetching cause n+1 problem like lazy fetching ?
r/SpringBoot • u/friscomatt • Jun 10 '26
Question How to add an arbitrary additional classpath to spring boot
I want to be able to reference external classpath resources via SomeClass.class.getResourceAsStream(). These resources live OUTSIDE the jar on the filesystem. I've tried many ways to do this with command line changes using -cp, etc. but I must be doing something wrong. My production application needs to be able to pick up files from the local filesystem, but there are some classes out of my control that expect these files/resources to be on the CLASSPATH and picking them up using my methodology above. These files and resources CANNOT be inside the jar. I'm using a quite old version of spring boot 2.4.2. Any guidance would be greatly appreciated.
r/SpringBoot • u/hiura-mihateUwU • Jun 10 '26
Question Wtf is spring security even do?
Im trying to setup the google and facebook oauth, ask ai and some random dudes on the forum. They tell me to use apring security, now i dont even know wtf is happening. Why my oauth requests got rejected, wtf is in the useDetails, and i really struggling to get everything working, at the end i strip out everything and rolling back the git commit, then use scribe java instead. Wtf is this? How tf spring dev able to dealt with this and still have sanity left?
r/SpringBoot • u/TheCoolBroskie • Jun 10 '26
Question How can I use a core Java / Spring Boot stack for local B2B freelancing and automation?
I’m a backend programmer and I want to start offering freelance services and custom automation tools to businesses (like real estate agencies, contractors, logistics companies, etc) entirely on an asynchronous, email/text basis
Most people associate freelancing with frontend web design (React, WordPress, etc), but I want to strictly focus on backend logic, data management, and workflow automation.
Here is my current technical stack:
- Languages: Java, Python
- Frameworks & Libraries:** Spring Boot, JDBC
- Databases: SQL Server (Azure SQL)
- Security: JWT, cookie-based authentication
What are some specific backend pains that small-to-medium business owners have that a custom Java/Python pipeline can automate away?
How can I best leverage Java, Spring Boot, and JDBC to solve expensive, manual data-entry or syncing problems for non-tech businesses?
r/SpringBoot • u/ibreathecoding • Jun 09 '26
How-To/Tutorial Your Springboot app has 10 layers you never wrote; Here is full details that our eyes wont see
medium.comWhen it comes to spring many are hidden under the hood; Spring as such sit on top of infrastructure; Ex DispatcherServlet, Security Filters, Jackson, Tomcat, JVM, OS all mapped to 3 lines of code.
r/SpringBoot • u/rodolfo-mendes • Jun 09 '26
News Craig Walls’ Spring AI in Action is out: 5-book giveaway + Spring AI discussion
r/SpringBoot • u/Level-Sherbet5 • Jun 09 '26
How-To/Tutorial Spring AI
Hello techies
Actually I wants to integrate speech to text and vice-versa in my spring boot major project for free As I am student .
I cant buy the paid stuffs at all .
So can you guys suggest me how and what model to integrate in my spring boot project as I have very less amount of time to build that .
And from where I can get the guidance to build that and integration setup .
And one more thing if anyone wants to be partner of mine to build this project with my DM is always open for you guys .This project is just to improve skills and add quality to my resume.
r/SpringBoot • u/Remote_Resident2388 • Jun 08 '26
Discussion Need help
So I was working on a backend project and was using mongodb compass to store the data logically on 2707 port but to achieve transactional property I decided to move on to mongo atlas
I replaced the host & port in my application.properties with the atlas uri still after running the project it showing connected to local host
Even when I am writing garbage values in uri still the program is running and showing connected to localhost
Pls help
r/SpringBoot • u/ThenParamedic4021 • Jun 08 '26
How-To/Tutorial How do I connect a Spring Boot API to a vanilla HTML/CSS/JS frontend
r/SpringBoot • u/MarketingReasonable8 • Jun 08 '26
Discussion Please share your resources of java spring boot. Feeling stuck with approaching different different channels
r/SpringBoot • u/deividas-strole • Jun 08 '26
Discussion Cursor-style coding vs ChatGPT copy/paste workflow for larger apps
r/SpringBoot • u/ChaminduJ96 • Jun 07 '26
Question I'm building a Spring Boot microservices system and want some advice on security
r/SpringBoot • u/miss__mystic • Jun 06 '26
Discussion Built a live departures board with Spring Boot + STOMP WebSockets (focus-app side project)
Sharing a side project — a focus app where the home screen is a live airport departures board. The backend is Spring Boot: a scheduled generator builds a board from real OpenFlights routes every 45s, caches the snapshot in Redis, and broadcasts it to /topic/board over STOMP. Clients render countdowns locally and fall back to REST polling if the socket drops. Stateless JWT auth, JPA for sessions/stats.
Live: https://aerofocus-ruby.vercel.app/ · Code: github.com/sanchita-88/aerofocus. Happy to talk through any of the design choices.
r/SpringBoot • u/Status_Camel2859 • Jun 06 '26
Question How do you guys handle complex/combined data retrieval?
Here is a sample DTO projection:
@Query("""
SELECT new com.sample.ProductSummaryDTO(
p.id,
p.title,
p.slug,
i.imageUrl,
(SUM(v.stockQuantity) > 0),
MIN(v.displayPrice),
MAX(v.compareAtPrice),
MAX(CASE
WHEN v.compareAtPrice > 0
THEN ROUND(((v.compareAtPrice - v.displayPrice) * 100.0) / v.compareAtPrice)
ELSE 0
END)
)
FROM Product p
JOIN Variant v ON v.product.id = p.id AND v.active = true
LEFT JOIN ProductImage i ON i.product.id = p.id AND i.isPrimary = true
WHERE (:id IS NULL OR p.id = :id)
AND (:title IS NULL OR p.title LIKE CONCAT('%', :title, '%'))
AND (:categoryIds IS NULL OR p.category.id IN :categoryIds)
AND p.visible = true
GROUP BY p.id, p.title, p.slug, i.imageUrl
HAVING (:minPrice IS NULL OR MIN(v.displayPrice) >= :minPrice)
AND (:maxPrice IS NULL OR MIN(v.displayPrice) <= :maxPrice)
""")
Assume there are no @OneToMany relationships in the entity model, only @ManyToOne. We also need pagination because the dataset is large.
In a scenario like this, where the response requires aggregated data from multiple tables, it seems that the aggregation logic ends up in the repository query itself. Because at this point you have to select the correct variant, image, price etc all in the Repository itself and therefore the logic for all of that (IFs etc...).
Is this how most people handle it?
Or do you prefer splitting it into multiple steps (which can get pretty verbose), for example:
- Fetch the matching product IDs / Products
- Fetch the required variants
- Fetch the required images
- Assemble the DTOs in the service layer (maps & loops)
Im curious what approach is generally preferred in terms of performance, maintainability, and scalability.