Latest / CyberSecurity Summary / Pro Spring Boot 3 with Kotlin: In-Depth Guide to Best Practices for Cloud-Native and Microservices Development
Transcript
- 0:00Speaker 1: Building modern software applications today. Wow, it often feels like
- 0:04Speaker 1: you're trying to navigate this this vast, ever expanding ocean,
- 0:09Speaker 1: doesn't it.
- 0:10Speaker 2: It really does. Frameworks, patterns, deployment strategies.
- 0:13Speaker 1: Yeah, the sheer volume can be overwhelming if you're trying
- 0:15Speaker 1: to stay informed and you know, build genuinely robust system.
- 0:20Speaker 2: Absolutely, the landscape just shifts constantly, trying to keep up
- 0:24Speaker 2: with every single new thing.
- 0:25Speaker 1: It's well, it leads to information overload pretty fast.
- 0:28Speaker 2: Right, which is why having a guide, some kind of
- 0:31Speaker 2: compass is just so.
- 0:32Speaker 1: Crucial exactly to cut through all the noise.
- 0:35Speaker 2: And that's exactly what we're bringing you today. We're diving
- 0:38Speaker 2: headfirst into the core of modern application development. We're pulling
- 0:41Speaker 2: out the really important nuggets from pro spring Boot three
- 0:45Speaker 2: with Cotlin, And this isn't just about code, right, It's
- 0:47Speaker 2: about understanding the why and the how behind these powerful
- 0:51Speaker 2: tools that honestly make a lot of the Internet just work.
- 0:55Speaker 1: And what's great here the source material comes from real experts,
- 0:58Speaker 1: Peter Spieth and Felid Gutierra and Febe brings insights straight
- 1:01Speaker 1: from VM where you know, the folks who actually create
- 1:04Speaker 1: spring boot. Wow. Okay, so straight from the.
- 1:07Speaker 2: Source, pretty much distilled down for clarity.
- 1:10Speaker 1: So our mission for this deep dive is really to
- 1:13Speaker 1: unpack how spring Boot, especially with Cotlin, takes these inherently
- 1:17Speaker 1: complex software development tasks and just simplifies them, radically simplifies them.
- 1:24Speaker 2: Yeah, show how it delivers these like surprising features right
- 1:27Speaker 2: out of the box.
- 1:27Speaker 1: Exactly and helps developers like you build apps that are fast,
- 1:32Speaker 1: secure and crucially observable and ready for the.
- 1:35Speaker 2: Cloud get ready for some aha moments. I think it
- 1:38Speaker 2: can really shift how you view building apps.
- 1:41Speaker 1: Think of this as your shortcut. We're cutting through the jargon,
- 1:44Speaker 1: getting straight to what's genuinely important.
- 1:46Speaker 2: And how you can actually apply to your own work
- 1:48Speaker 2: right pretty much immediately.
- 1:50Speaker 1: Okay, let's start with Springboot's core promise, then simplification and opinionation.
- 1:56Speaker 1: So why spring Boot. The book makes it clear it's
- 1:59Speaker 1: designed ground to be enterprise ready.
- 2:01Speaker 2: Right with best practices just applied automatically.
- 2:04Speaker 1: And that's the key.
- 2:05Speaker 2: That's the key. The biggest advantage honestly, and it's a
- 2:07Speaker 2: game changer for productivity, is that opinionated nature, meaning it.
- 2:12Speaker 1: Makes choices for you sensible defaults.
- 2:15Speaker 2: Exactly, sensible defaults, yeah, which leads to what the authors
- 2:18Speaker 2: call sometimes zero configuration.
- 2:21Speaker 1: Zero configuration. Okay, that sounds almost too good to be true.
- 2:24Speaker 1: How much pain does that actually save?
- 2:26Speaker 2: Well, think about the old days, right, all that XML
- 2:29Speaker 2: or just tons of Java configu code just to get
- 2:31Speaker 2: a basic web app talking to a database.
- 2:34Speaker 1: Oh yeah, hours, sometimes days.
- 2:37Speaker 2: Spring boots autoconfiguration isn't just convenient, it's like the whole
- 2:40Speaker 2: paradigm shift. It means you can focus on your actual
- 2:43Speaker 2: business logic, like from day.
- 2:45Speaker 1: One, trusting the framework to wire up most of the infrastructure.
- 2:48Speaker 2: Yeah, like ninety percent of it intelligently. It frees you
- 2:51Speaker 2: from that boiler plate, letting you build complex stuff without
- 2:54Speaker 2: getting bogged down and repetitive setup.
- 2:56Speaker 1: That is a huge claim about productivity. But does that
- 2:59Speaker 1: opinionated nature does it ever become a limitation? Do those
- 3:03Speaker 1: defaults ever get in your way?
- 3:05Speaker 2: It's a fair question. I mean, while it massively cuts
- 3:07Speaker 2: down initial development time, sure there are times you need finer.
- 3:11Speaker 1: Control, but you can override things.
- 3:13Speaker 2: Oh yeah, absolutely. Springboot is designed to let you step
- 3:16Speaker 2: in and override defaults pretty easily when you need to. Okay,
- 3:20Speaker 2: and connecting this to the bigger picture, this whole approach
- 3:23Speaker 2: also makes Springboot perfect for cloud native applications. It follows
- 3:28Speaker 2: those twelve factor app principles right.
- 3:31Speaker 1: The best practices for building scalable cloud.
- 3:33Speaker 2: Apps exactly, things like dependency management, logging, config It handles
- 3:38Speaker 2: that well. And it also sets you up for native
- 3:41Speaker 2: images using AOT compilation with Grail VM.
- 3:45Speaker 1: Which is huge for performance in the cloud. We'll definitely
- 3:47Speaker 1: circle back to that, but let's stick into the magic
- 3:50Speaker 1: a bit more. How does this autoconfiguration actually work? What
- 3:53Speaker 1: happens when I run my app?
- 3:55Speaker 2: So it all kicks off with the spring application class
- 3:57Speaker 2: in Cotland. Your main method basically run this singleton, okay,
- 4:01Speaker 2: but the real powerhouse, the thing you see everywhere is
- 4:04Speaker 2: the at spring boot application.
- 4:05Speaker 1: Annotation right, that one annotation, yeah.
- 4:08Speaker 2: And it's actually an alias for three other critical ones
- 4:10Speaker 2: You've got at spring boot configuration, which marks the class
- 4:14Speaker 2: as a config source. At enable autoconfiguration, which is the
- 4:18Speaker 2: trigger really. It starts the autoconfig based on what dependencies
- 4:21Speaker 2: it finds on your class path.
- 4:23Speaker 1: Ah, so it looks at my library exactly.
- 4:25Speaker 2: And the third is that component scan which finds your
- 4:28Speaker 2: own components, your controllers, services, that kind of thing.
- 4:30Speaker 1: So if I just add, say the post Rascal driver
- 4:34Speaker 1: dependency to my project. Yep, springboot sees that and just
- 4:38Speaker 1: sets up a data source and maybe a transaction manager
- 4:42Speaker 1: without me writing any code for it.
- 4:44Speaker 2: That's precisely it. It sounds like a dream, but it works.
- 4:47Speaker 2: It configures essentials, transaction manager for transactions, entity manager, factory
- 4:52Speaker 2: if you're using JPA, the data source for connections, message
- 4:55Speaker 2: converters for web stuff, even resource handler registry for static files.
- 4:59Speaker 1: All that plumbing just handled, all.
- 5:01Speaker 2: Handled without XML, without manual Java config beans most of
- 5:04Speaker 2: the time.
- 5:04Speaker 1: That's genuinely impressive. But what if I don't want one
- 5:08Speaker 1: of those defaults. Say I have a really custom setup
- 5:10Speaker 1: for web stuff, you can.
- 5:11Speaker 2: Definitely control it that it enables autoconfiguration annotation, it has
- 5:16Speaker 2: exclude and exclude name parameters. Ah okay, So if you
- 5:19Speaker 2: didn't want the standard WEBNBC setup, you could just say
- 5:23Speaker 2: exclude array of WEBMVC, autoconfiguration dot class. So you get
- 5:28Speaker 2: the convenience, but you still have control.
- 5:30Speaker 1: That's a good balance, okay. Shifting gears slightly. The book
- 5:33Speaker 1: talks about personalizing your app beyond the core configuration. I
- 5:37Speaker 1: was kind of amused by the custom banner thing.
- 5:40Speaker 2: Yeah, it's a small touch, but it shows the level
- 5:42Speaker 2: of detail instead of the default spring boot ask.
- 5:45Speaker 1: Art, which is iconic but maybe not for every app.
- 5:47Speaker 2: Right, you can just drop a banner dot txt file
- 5:50Speaker 2: in src in main resources or set the spring dot
- 5:53Speaker 2: banner dot location property.
- 5:55Speaker 1: You can even use online generators right like patoorjk dot com.
- 5:58Speaker 2: Yep makes something unique, or just turn it off completely
- 6:01Speaker 2: with banner mode doff. It's simple but nice to have
- 6:05Speaker 2: that option.
- 6:06Speaker 1: So even the visual startup is configurable. What about passing
- 6:09Speaker 1: arguments when you launch the app for different modes or environments?
- 6:12Speaker 2: Spring good makes that super easy with the Application Arguments interface.
- 6:15Speaker 1: Okay.
- 6:16Speaker 2: Lets you easily grab both option arguments you know, things
- 6:18Speaker 2: like enable or option value one exactly, and also non
- 6:23Speaker 2: option arguments maybe like command words update or upgrade. Really
- 6:27Speaker 2: useful for passing parameters at run time?
- 6:30Speaker 1: And what about the app's life cycle? Are there hooks
- 6:33Speaker 1: for running code at specific startup points?
- 6:36Speaker 2: Yes, and there's a clear order. First, application runner gets
- 6:40Speaker 2: called it gets those nice parsed application arguments. Then command
- 6:44Speaker 2: line runner runs it gets the rostering arguments if you
- 6:46Speaker 2: need those for some reason.
- 6:47Speaker 1: The final signal the.
- 6:49Speaker 2: Very last event signaling everything's initialized and ready to go.
- 6:53Speaker 2: Is the application ready event? Understanding that sequence helps you
- 6:56Speaker 2: plug in custom logic at the right time.
- 6:58Speaker 1: That's a clear progression. Good to know. But once the
- 7:01Speaker 1: app's running, how do we handle settings? You know, avoid
- 7:04Speaker 1: hardcoding data based passwords everywhere. Let's get into configuration management.
- 7:08Speaker 2: Okay, For basic single properties, you can just inject them
- 7:11Speaker 2: using at value property.
- 7:13Speaker 1: Name right, using that Spring expression language to an el exactly.
- 7:16Speaker 2: Spitteel gives you a lot of power there. It pulls
- 7:18Speaker 2: values straight from your application dot properties or application dot
- 7:22Speaker 2: EML file.
- 7:23Speaker 1: But what if I have a bunch of related settings,
- 7:25Speaker 1: like all the connection details for some service, server, port, username,
- 7:31Speaker 1: at value for each one seems messy?
- 7:33Speaker 2: It would get messy fast. And that's where at configuration
- 7:36Speaker 2: properties is fantastic. You can bind a whole group of
- 7:39Speaker 2: properties like users, dot serve, dot server, users, dot service,
- 7:42Speaker 2: dot port all into a single type safe class. Keeps
- 7:46Speaker 2: things super clean and organized much better for maintainability.
- 7:49Speaker 1: Nice And where did these properties actually come from? Is
- 7:53Speaker 1: there a hierarchy? Like can an environment variable override something
- 7:57Speaker 1: in my packaged application?
- 7:59Speaker 2: Absolutely? And that's crue. Spring boot looks in multiple places
- 8:02Speaker 2: application dot properties inside your jar first, then it looks
- 8:05Speaker 2: for the same file outside the jar. Then environment variables,
- 8:09Speaker 2: command line arguments, and the later ones win exactly. External
- 8:12Speaker 2: sources always overwrite internal ones. So yes, an environment variable
- 8:16Speaker 2: set in your deployment will trump a value inside the jar.
- 8:18Speaker 2: Super useful for different environments.
- 8:20Speaker 1: Takes total sense for cloud deployments and specifically for web apps.
- 8:24Speaker 1: How does boot know whether to set up, for say, Tomcat,
- 8:26Speaker 1: or for reactive netty.
- 8:28Speaker 2: It smartly adapts based on your dependencies. If it sees
- 8:31Speaker 2: Spring Bootstarter web, it assumes web application type servlet traditional
- 8:36Speaker 2: blocking IO, usually with embedded Tomcat, okay. But if it
- 8:39Speaker 2: find Spring Bootstarter web flux, it switches to web application
- 8:42Speaker 2: type reactive, typically using Netty underneath for non blocking reactive handling.
- 8:47Speaker 1: So it just figures it out based on what you include.
- 8:49Speaker 2: GEP adapts seamlessly.
- 8:51Speaker 1: Okay, that's flexible. Let's shift now to actually building things
- 8:54Speaker 1: web development. First, classic question, at controller versus at rest control?
- 9:00Speaker 1: What's the deal?
- 9:01Speaker 2: Right? At rest controller is basically just a shortcut. It
- 9:03Speaker 2: combines at controller with at response body.
- 9:06Speaker 1: Okay, and what does that response body do? Again?
- 9:08Speaker 2: It tells Spring that the return value of your method
- 9:11Speaker 2: should be bound directly to the web response body, usually
- 9:14Speaker 2: serialized as JSON by default.
- 9:16Speaker 1: So at rest controller implies you're building an API that
- 9:19Speaker 1: returns data like JSON.
- 9:21Speaker 2: Exactly. If you used a plane at controller, you typically
- 9:24Speaker 2: return like a view name for rendering HTML. If you
- 9:27Speaker 2: wanted that controller to return JSON, you'd have to add
- 9:30Speaker 2: at response body yourself. So for rest APIs at rest
- 9:35Speaker 2: controller is almost always what you want.
- 9:36Speaker 1: Got it that clears it up and static content HTML, CSS, JavaScript?
- 9:41Speaker 1: Do I need a Patchy or Niekens in front Nope.
- 9:43Speaker 2: Spring boot handles it automatically. It serves static content from
- 9:47Speaker 2: standard locations in your class path, static public resources, or
- 9:51Speaker 2: meta in free sources.
- 9:52Speaker 1: So I just put my files there.
- 9:54Speaker 2: Just put them there, and if you have an index
- 9:55Speaker 2: dot html in one of those spots, boom, that's your
- 9:57Speaker 2: home page. No extra config needed.
- 10:00Speaker 1: Super handy. How about response formats like automatically getting JSON
- 10:04Speaker 1: or maybe XML if a client asks for it.
- 10:06Speaker 2: That's handled by HTPP message converters. Spring Boot sets these
- 10:10Speaker 2: up for you. Jason works out of the box because
- 10:12Speaker 2: the Jackson library is included with the webstarter and XML.
- 10:15Speaker 2: If you add the Jackson XML extension dependency. Boot will
- 10:19Speaker 2: automatically configure an XML converter two. Then it uses content
- 10:22Speaker 2: negotiation based on the clients accept hitter to decide whether
- 10:25Speaker 2: to send Jason or XML pretty.
- 10:27Speaker 1: Smart okay, and can I tweak that Jason Serialization dates,
- 10:32Speaker 1: for instance, can be formatted weirdly sometimes.
- 10:34Speaker 2: Yep, easy fix. The default is a long ISO eight
- 10:38Speaker 2: six oh one ish format, but you can change it
- 10:41Speaker 2: globally with the spring dot Jackson dot datebomat property in
- 10:45Speaker 2: application dot properties tailor it. However, you need.
- 10:48Speaker 1: Good What about validating incoming data? Preventing bad data before
- 10:53Speaker 1: it even hits my logic?
- 10:54Speaker 2: Absolutely essential? Spring Boot integrates smoothly with the Jakarta validation API.
- 10:58Speaker 1: So I can use annotation like at n blank exactly
- 11:01Speaker 1: and not blank at not null at email at size,
- 11:04Speaker 1: put them right on the fields of your request objects.
- 11:06Speaker 2: If validation fails, spring Boot automatically handles it, usually returning
- 11:10Speaker 2: a four hundred bad request with details. Keeps bad data out.
- 11:14Speaker 1: And broader error handling. If something unexpected blows up deeper
- 11:17Speaker 1: in my code, how do I give a clean error.
- 11:19Speaker 2: Response for that? You use at controller advice along with
- 11:22Speaker 2: at exception handler. This lets you centralize your exception handling logic.
- 11:25Speaker 1: So one place to catch specific exceptions.
- 11:28Speaker 2: Right, you can catch a custom retroboard not found exception
- 11:31Speaker 2: for example, and format a nice consistent Jason error response
- 11:35Speaker 2: across your whole API. Keeps your controllers cleaner.
- 11:39Speaker 1: Okay, that makes sense. And mapping request to controller methods
- 11:42Speaker 1: still the usual suspects like at get mapping, YEP at.
- 11:44Speaker 2: Request mapping is the general one, but you'll mostly use
- 11:47Speaker 2: the specifics at get mapping, at post mapping, at put mapping,
- 11:50Speaker 2: at delete mapping. They map directly to the HDDP methods.
- 11:53Speaker 1: And they support things like path variable.
- 11:55Speaker 2: Oh yeah, pathvariables like email to pull values from the URL,
- 11:59Speaker 2: plus flexibly use URL patterns using wild cards. You can
- 12:02Speaker 2: also use response entity to have full control over the response,
- 12:05Speaker 2: including headers like location.
- 12:07Speaker 1: After creating something cool, okay, weblayer covered Now data Every
- 12:11Speaker 1: app needs data persistence. How does boot simplify sl and
- 12:15Speaker 1: no SQL databases? Let's start with SQL for SQL.
- 12:19Speaker 2: The moment you add a database driver like the Postgres
- 12:21Speaker 2: school one or do postgrisk, Correll, dot PRIs, aggressive, zeris
- 12:25Speaker 2: growth counter Spring Boot auto configures.
- 12:28Speaker 1: Things like the data source exactly.
- 12:29Speaker 2: It sets up the data source and configures an efficient
- 12:32Speaker 2: connection pool usually high CARICP by default without you doing anything.
- 12:36Speaker 1: Wow, okay, no manual connection pool setup Nope.
- 12:39Speaker 2: Saves a ton of boiler plate and ensures good performance
- 12:42Speaker 2: right away.
- 12:43Speaker 1: And what else does the framework offer for SQL?
- 12:45Speaker 2: Well, the broader Spring framework gives you transaction management, so
- 12:48Speaker 2: you can just annotate methods with at transactional and JDBC template,
- 12:53Speaker 2: which massively simplifies raw JDBC code if you need to
- 12:56Speaker 2: go that low level removes all that trycatch finally.
- 12:59Speaker 1: Mess right the plan reduction again? What about setting up
- 13:02Speaker 1: the database schema initially, especially for testing or local dev
- 13:05Speaker 1: with embedded databases.
- 13:07Speaker 2: Boot can auto initialize embedded databases like H two hsql derby.
- 13:12Speaker 2: It looks for schema dot sql to create tables and
- 13:15Speaker 2: data dot sql to populate them in your class path.
- 13:17Speaker 1: Oh nice.
- 13:18Speaker 2: It's even smart enough to look for platform specific scripts
- 13:21Speaker 2: like schema dash H two dot sql or Schema dash
- 13:24Speaker 2: postrescl dot sql. You can control which platform it uses
- 13:28Speaker 2: with Spring dot sql dot in it dot platform.
- 13:31Speaker 1: Very convenient for quick starts. Okay, moving up a level
- 13:33Speaker 1: to Spring data, that's a big deal. What's the core idea? There.
- 13:36Speaker 2: Spring Data revolves around repository interfaces think cred repository or
- 13:41Speaker 2: paging and sorting repository.
- 13:43Speaker 1: So I just define an interface.
- 13:44Speaker 2: You define an interface that extends one of those, and bam,
- 13:48Speaker 2: you instantly get standard methods like save fine by I,
- 13:51Speaker 2: find old, delete biog implemented for.
- 13:53Speaker 1: You without writing any SQL often.
- 13:55Speaker 2: Yes, it uses query derivation based on method names. If
- 13:59Speaker 2: you name a method find by email string email, spring
- 14:02Speaker 2: data figures out the query. It's pretty magical.
- 14:05Speaker 1: That is a huge time saver. Okay, so what about
- 14:07Speaker 1: the specific implementations like Spring data JDBC.
- 14:10Speaker 2: Spring Data JDBC gives you enhanced support on top of
- 14:13Speaker 2: plane JDBC. It's built around the aggregate root concept from
- 14:17Speaker 2: Domain driven Design Aggregate root. Yeah, it helps you model
- 14:20Speaker 2: your data relationships cleanly, ensuring consistency, especially when you have
- 14:24Speaker 2: complex optic graphs. It uses things like aggregate reference to
- 14:27Speaker 2: manage links between entities.
- 14:29Speaker 1: Okay, and the really popular one, Spring and Data JPA.
- 14:32Speaker 2: Right. JPA simplifies using the jag of Persistence API, boot,
- 14:35Speaker 2: auto Computers, a data source platform, Transaction Manager, NAT Manager,
- 14:39Speaker 2: factory all the JPA infrastructure.
- 14:42Speaker 1: And I just use annotations on my classes exactly at
- 14:45Speaker 1: entity to market class at ID for the primary key,
- 14:48Speaker 1: at generated value for generated IDs, at many, tone, at
- 14:51Speaker 1: many tominy for relationships. And it can create the tables too, Right,
- 14:54Speaker 1: I don't need schema dot A scale anymore often.
- 14:57Speaker 2: Yes, JPA providers like Hibernate can generate the DDL Data
- 15:01Speaker 2: Definition Language to create or update your schema based on
- 15:04Speaker 2: your entity definitions when the app starts. Another big simplification.
- 15:08Speaker 1: Wow. Okay, so that's data access covered. But what if
- 15:12Speaker 1: I want to expose this data as a rest API
- 15:14Speaker 1: without writing any controllers myself? Is that possible?
- 15:17Speaker 2: It absolutely is. That's where Spring Data rest comes in.
- 15:20Speaker 2: It's amazing.
- 15:21Speaker 1: What does it do.
- 15:21Speaker 2: It automatically builds a hyper media driven rest API directly
- 15:25Speaker 2: from your Spring Data repository interfaces. Just add the dependency seriously,
- 15:29Speaker 2: just like that, pretty much. Add the Spring Data restel
- 15:32Speaker 2: explorer starter and you instantly get a discoverable API explore
- 15:36Speaker 2: at http dot localhost dot a zero ad R. You
- 15:39Speaker 2: can browse your resources, see the endpoints. It's incredible for
- 15:42Speaker 2: rapid API prototyping.
- 15:43Speaker 1: An API explorer pops up automatically. That's fantastic.
- 15:46Speaker 2: Yeah, and you can customize the endpoint paths, the names
- 15:49Speaker 2: used for resources, and so on using the at repository
- 15:53Speaker 2: rest resource annotation if the defaults aren't perfect.
- 15:56Speaker 1: Okay, that's seriously powerful. Now, what about new SQL databases
- 16:01Speaker 1: like Mango dB or reddis is integration just as smooth.
- 16:05Speaker 2: Pretty much. Yeah. For Mango dB adds Spring Bootstarter data.
- 16:08Speaker 2: Mangun boot auto configures the connection you typically interact using
- 16:13Speaker 2: Mango template or Mongo.
- 16:14Speaker 1: Operations anything specific to now like with Docker.
- 16:16Speaker 2: Yeah, if you're using doctor composed, make sure to set
- 16:18Speaker 2: the Mango endb database environment variable so it knows which
- 16:21Speaker 2: database to initialize. Oh, in Spring data, Mango dB adds
- 16:25Speaker 2: a class field to your documents to help with mapping
- 16:27Speaker 2: back to Java objects.
- 16:28Speaker 1: Okay, and reddis for cashing or key value stuff.
- 16:32Speaker 2: Similar story, add Spring Bootstarter data reddis. You can map
- 16:35Speaker 2: your Java objects to Rettis hashes using the at rettis
- 16:38Speaker 2: hash annotation. It stores data with clear keys like retroboard
- 16:41Speaker 2: for the type and retroboard dot ued for specific instances.
- 16:45Speaker 1: So SQL or nosea boot really smooths out the setup
- 16:49Speaker 1: and basic operations. Okay, let's switch paradigms completely reactive programming.
- 16:54Speaker 1: The book mentions the Reactive Manifesto. What's the core idea there?
- 16:57Speaker 2: The Reactive Manifesto back from twenty fourteen lays out the
- 17:01Speaker 2: traits of reactive systems. They need to be responsive, resilient,
- 17:04Speaker 2: elastic and message driven.
- 17:06Speaker 1: So quick, fault tolerant, scalable and using async messages exactly.
- 17:11Speaker 2: It's about building systems that handle load and failure gracefully.
- 17:15Speaker 2: Using asynchronous communication and back pressure is key so components
- 17:18Speaker 2: don't get overwhelmed. It's a different way of thinking compared
- 17:21Speaker 2: to traditional blocking code.
- 17:23Speaker 1: A big shift. And how does Spring implement this on
- 17:26Speaker 1: the JVM?
- 17:26Speaker 2: Primarily through Project Reactor. It's a library based on the
- 17:29Speaker 2: reactive stream specification that's a standard for ACYNC stream processing
- 17:33Speaker 2: with back pressure. Reactor brings this non blocking, event driven
- 17:36Speaker 2: approach to Java.
- 17:38Speaker 1: And what are the main building blocks developers use in reactor?
- 17:41Speaker 2: The two core types are monot and flux.
- 17:43Speaker 1: T Mono andflux okay.
- 17:45Speaker 2: Mono represents the stream of zero or one item. Think
- 17:48Speaker 2: of it like an ACNC optional. Flux represents the stream
- 17:52Speaker 2: of zero to n items. It's an asynchronous sequence.
- 17:55Speaker 1: Got it? And when you use this with springboot, how
- 17:57Speaker 1: do you reactive web and data look different.
- 18:00Speaker 2: For reactive web you add spring boots Starter web flux boot,
- 18:04Speaker 2: autoconfigures it, and crucially it defaults to using Netty instead
- 18:08Speaker 2: of Tomcat as the server.
- 18:09Speaker 1: Because netti is non blocking.
- 18:11Speaker 2: Exactly ensures the whole iostack is non blocking. For reactive
- 18:15Speaker 2: data access, you'd use reactive repository interfaces like reactive CRUD repository, so.
- 18:20Speaker 1: The entire request path from web to database and back
- 18:23Speaker 1: can be non blocking.
- 18:24Speaker 2: That's the goal. It's essential for applications needing really high
- 18:27Speaker 2: concurrency and low latency.
- 18:29Speaker 1: Okay, a powerful option for specific needs. Now let's talk
- 18:33Speaker 1: about communication within and between applications using messaging. How does
- 18:37Speaker 1: spring boot handle events?
- 18:39Speaker 2: Well, Spring itself has core events like context refreshed event.
- 18:42Speaker 2: Spring boot adds its own like application ready event. We
- 18:44Speaker 2: mentioned that one earlier fires when the app is fully ready.
- 18:47Speaker 1: Can I create my own events for internal communication like
- 18:50Speaker 1: decoupling parts of my app?
- 18:52Speaker 2: Oh? Absolutely, it's a great pattern. You can create custom
- 18:55Speaker 2: event classes by extending application event or even simpler, just
- 18:59Speaker 2: anne tape method with at event listener.
- 19:01Speaker 1: So I could have say a user activated event.
- 19:04Speaker 2: Exactly publish that event when a user becomes active. Then
- 19:07Speaker 2: have another component listen for at event listener and if
- 19:09Speaker 2: you want the listener to run without blocking the publisher,
- 19:12Speaker 2: just add at at ASNC. Really powerful for loose coupling.
- 19:15Speaker 1: Nice. What about more traditional messaging systems JMS.
- 19:19Speaker 2: Easy integration, add the starter for active MQ Spring Bootstarter,
- 19:23Speaker 2: Active MQ or Artemis Spring bootstarter.
- 19:25Speaker 1: Artemis and sending and receiving.
- 19:27Speaker 2: You use JMS template dot convert and send to publish messages.
- 19:31Speaker 2: To listen, you just annotate a method with at JMS
- 19:33Speaker 2: listener specifying the Q or topic.
- 19:36Speaker 1: Name and pubsub versus point to point.
- 19:38Speaker 2: Simple property dot spring dot JMS dot pubsubdomain true switches
- 19:42Speaker 2: it to topic mode published subscribe.
- 19:45Speaker 1: Okay, straightforward. What about AMQP and RabbitMQ that has more
- 19:48Speaker 1: complex concepts right exchanges, bindings it.
- 19:50Speaker 2: Does MQP uses exchanges, bindings and queues. Messages go to
- 19:55Speaker 2: an exchange first. Bindings are rules that wrote messages from
- 19:58Speaker 2: an exchange to specific queues. Queues are where consumers pick
- 20:02Speaker 2: messages up.
- 20:03Speaker 1: So the exchanges like the central post office, bindings are
- 20:05Speaker 1: the sorting rules. Queues are the mailboxes.
- 20:07Speaker 2: Perfect analogy, and there are different types of exchanges for
- 20:11Speaker 2: different routing logic direct uses a specific routing key, fan
- 20:15Speaker 2: out broadcast to all bound cues. Topic uses wildcard routing
- 20:20Speaker 2: keys like user or audit hashtag headers roots based on
- 20:24Speaker 2: message headers.
- 20:25Speaker 1: Lots of flexibility there. How to spring AMQP help.
- 20:29Speaker 2: It gives you annotations like at rabbit listener to easily
- 20:31Speaker 2: consume messages, and you can programmatically declare queues, exchanges and
- 20:36Speaker 2: bindings using at qu at exchange and at que binding annotations,
- 20:40Speaker 2: which simplifies set up a lot.
- 20:42Speaker 1: Okay, powerful routing options. What about real time two way
- 20:45Speaker 1: communication like for chat apps or live dashboards?
- 20:48Speaker 2: For that, you typically use web sockets. It's a protocol
- 20:51Speaker 2: providing full duplex communication over a single TCP connection. Client
- 20:55Speaker 2: and server can both send messages anytime, and.
- 20:57Speaker 1: People often use STOMP over web sockets.
- 21:00Speaker 2: Yes. STOMP simple text oriented messaging protocol adds a layer
- 21:04Speaker 2: on top providing message headers, destinations, and a pub submodel,
- 21:08Speaker 2: making it easier to route messages to specific users or
- 21:11Speaker 2: topics within the web socket connection.
- 21:13Speaker 1: How do you set that up? In boot?
- 21:15Speaker 2: Add Spring Bootstarter web socket UH on the server you
- 21:19Speaker 2: use at enable web socket message broker and configure endpoints
- 21:22Speaker 2: and brokers using web socket message broker configure.
- 21:25Speaker 1: And the book also mentions our socket what's that for?
- 21:28Speaker 2: Our socket is a newer binary protocol designed for high performance,
- 21:32Speaker 2: low latency communication, especially between micro services.
- 21:35Speaker 1: Binary not tech space.
- 21:37Speaker 2: Right, and it supports more interaction models than just request response.
- 21:41Speaker 2: You have fire and forget request stream, server streams, data
- 21:44Speaker 2: back and channel fully bi directional streams.
- 21:47Speaker 1: How do you use it with springboot ad.
- 21:49Speaker 2: Spring bootstarter socket? You use our socket request or on
- 21:52Speaker 2: the client side and at message mapping on the server
- 21:54Speaker 2: side to handle incoming requests or streams. It's geared towards
- 21:58Speaker 2: high throughput scenarios.
- 21:59Speaker 1: Okay, so boot really covers the whole spectrum of communication needs.
- 22:03Speaker 1: Now let's talk about getting these apps production ready spring Boot.
- 22:07Speaker 1: Actuator is key here right for observability.
- 22:10Speaker 2: Absolutely, Actuator is your go to for production insights. Yeah.
- 22:14Speaker 2: It exposes a ton of useful information and management endpoints
- 22:17Speaker 2: over HTTP or JMX, think metrics, health checks, environment variables,
- 22:22Speaker 2: thread dumps, logger levels.
- 22:24Speaker 1: Like a built in dashboard for your apps internals kind of.
- 22:27Speaker 2: Yeah. It gives monitoring tools the hooks they need.
- 22:30Speaker 1: What are the most critical endpoints?
- 22:31Speaker 2: The main prefix is actuator. The most important one enabled
- 22:35Speaker 2: by default is actuator Health. It gives a basic updown
- 22:37Speaker 2: status but can be customized to check dependencies too and others.
- 22:41Speaker 2: Actuator info for app info, Actuator Metrics for detailed metrics,
- 22:45Speaker 2: Actuator loggers to view and change log levels on the fly,
- 22:49Speaker 2: Actuator beans to see all the Spring beans, Actuator events
- 22:52Speaker 2: for environment properties, Actuator audit events for security stuff. Lots
- 22:56Speaker 2: of useful ones?
- 22:57Speaker 1: Are they all enabled by default? Seems like some could be?
- 22:59Speaker 2: Some good point? No, Only health and sometimes info are
- 23:03Speaker 2: exposed over HTTP by default. You need to explicitly enable
- 23:07Speaker 2: others using the management Dot endpoints dot web dot exposure DOT.
- 23:11Speaker 3: Include property like health infometrics exactly, and for sensited ones
- 23:16Speaker 3: like loggers or envy, you absolutely must secure them, usually
- 23:20Speaker 3: by integrating Actuator with Spring security and requiring a specific
- 23:24Speaker 3: role like actuator admin makes sense.
- 23:26Speaker 1: Can I create my own Actuator endpoints for application specific stuff?
- 23:30Speaker 2: Yep, It's surprisingly easy. You create a class annotated with
- 23:33Speaker 2: that endpoint, and then methods inside annotated with that readoperation
- 23:37Speaker 2: for deed, at write operation for PSD or at delete
- 23:40Speaker 2: operation lets you expose custom state or operations.
- 23:43Speaker 1: What about custom health checks, like checking if a downstream
- 23:47Speaker 1: service is reachable?
- 23:48Speaker 2: Definitely you implement the health Indicator interface. This lets you
- 23:51Speaker 2: plug in custom logic, check a database, call an external API,
- 23:54Speaker 2: verify a business rule, and have its status contribute to
- 23:57Speaker 2: the overall Actuator health endpoint a much riger picture of health.
- 24:01Speaker 1: Okay, and for the full observability trifecta metrics, logs tracing.
- 24:05Speaker 1: How does actuator fit in?
- 24:06Speaker 2: Actuator is the main integration point, especially for metrics. It
- 24:10Speaker 2: uses micrometer underneath micrometer. Yeah, it's a vendor neutral application
- 24:14Speaker 2: metrics facade think SLF four J. But for metrics, Actuator
- 24:19Speaker 2: exposes micrometer metrics.
- 24:20Speaker 1: Can I add my own business metrics easily?
- 24:22Speaker 2: Yes? You can inject the meter registry and create counters, timers,
- 24:26Speaker 2: gauges directly, or even better, use the ad observed annotation
- 24:30Speaker 2: from Micrometer Observation AOP for a more declarative approach. You
- 24:35Speaker 2: can also use things like handler interceptor to automatically time
- 24:38Speaker 2: web requests.
- 24:39Speaker 1: Okay, So metrics are covered. What about logs and distributed tracing?
- 24:43Speaker 2: For logs, you typically can figure something like log back
- 24:45Speaker 2: using logbackspring dot xml to output structured logs like JSON
- 24:50Speaker 2: and then ship them off to a log aggregation system
- 24:53Speaker 2: like Grafonoloki or elastic search.
- 24:55Speaker 1: And tracing across micro services.
- 24:57Speaker 2: For that you integrate with distributed tracing systems. Spring Boot
- 25:01Speaker 2: has great support for Jaeger and Zipkin, often visualized with
- 25:04Speaker 2: Graffana Tempo. My Chrometer Tracing handles the instrumentation.
- 25:07Speaker 1: And Graffana brings it all together exactly.
- 25:10Speaker 2: Use Prometheus often to scrape the actuated Prometheus metrics endpoint
- 25:15Speaker 2: looking for logs, Tempo for traces, and then Graffana provides
- 25:18Speaker 2: the unified dashboards to visualize everything. That's your full observability stack.
- 25:22Speaker 1: That's a comprehensive setup. Okay, ensuring quality before production testing.
- 25:27Speaker 1: How does springboot help there?
- 25:29Speaker 2: It builds on the standard spring test framework but adds
- 25:31Speaker 2: autoconfiguration goodness. The main tool for integration testing is at springboot.
- 25:35Speaker 1: Test and that loads the whole application context.
- 25:38Speaker 2: Yes, it loads the full context, making it very realistic.
- 25:41Speaker 2: You can control the web environment, random port, moc numbi,
- 25:45Speaker 2: past properties ARGs. It's flexible but can be slower.
- 25:49Speaker 1: Right, loading everything can be slow. What if I just
- 25:51Speaker 1: want to test one layer like my web controllers.
- 25:53Speaker 2: That's where test likeses are brilliant. They load only the
- 25:56Speaker 2: parts of the context relevant to a specific layer, making
- 25:58Speaker 2: tests much faster. Example, at webmvictest is a big one.
- 26:02Speaker 2: It focuses just on the web layer, your controllers, filters,
- 26:04Speaker 2: et cetera. It auto configures mock them VC for sending
- 26:07Speaker 2: mock HTTP requests and often uses at mockbeing to mock
- 26:11Speaker 2: out service dependencies.
- 26:12Speaker 1: So you test the controller in isolation pretty much.
- 26:15Speaker 2: There's also at json test for testing Jason serial de
- 26:20Speaker 2: serialization logic.
- 26:21Speaker 1: Specifically, and for the data layer testing repositories.
- 26:24Speaker 2: You have slices like at data JPay tests for jpa
- 26:28Speaker 2: at data, Mango tests for manga deb at data edis
- 26:30Speaker 2: test at jdbt tests. These load just a data configuration
- 26:34Speaker 2: and often use an embedded database or mock the noseql client.
- 26:38Speaker 1: But embedded databases aren't always the same as production. How
- 26:41Speaker 1: do you test against a real database like postgress bowl reliably?
- 26:45Speaker 2: That's the perfect use case for test containers. It's fantastic
- 26:47Speaker 2: that does it work. You annotate your test class to
- 26:50Speaker 2: use a container like a container for a post riscal
- 26:52Speaker 2: container test container starts a real postgressfol instance in Docker
- 26:56Speaker 2: just for your test run.
- 26:57Speaker 1: Wow, a real database instance.
- 26:59Speaker 2: For tests yep, and with at service connection, spring Boot
- 27:02Speaker 2: tests can automatically configure your application context to connect to
- 27:05Speaker 2: that container. It makes integration tests incredibly reliable. The at
- 27:10Speaker 2: restart scope annotation is also useful to keep the container
- 27:13Speaker 2: running between test methods in the same class, speeding things up.
- 27:16Speaker 1: That's amazing for confidence, okay, equally critical security. How does
- 27:22Speaker 1: spring boot security work under the hood.
- 27:24Speaker 2: It's built around a chain of servelet filters. The entry
- 27:27Speaker 2: point is usually delegating filter proxy, which passes the request
- 27:30Speaker 2: to a filterchain proxy. This proxy manages multiple security filter
- 27:35Speaker 2: chain instances, each potentially handling different URL patterns or security concerns.
- 27:40Speaker 2: It processes the HTTP servelet request and HTTP servelet response.
- 27:45Speaker 1: How do I add it to my project?
- 27:46Speaker 2: Just add the spring boot starter security dependency. Springboot autoconfigures
- 27:50Speaker 2: basic security immediately, which means usually it enables HTTP basic
- 27:54Speaker 2: informed log in, secures all end points by default, and
- 27:57Speaker 2: generates a default user with a random password into the
- 28:00Speaker 2: console and startup just enough to get you started securely.
- 28:02Speaker 1: How do I manage users properly, not just the default
- 28:05Speaker 1: and memory one.
- 28:06Speaker 2: For simple cases, you can configure in memory user details manager,
- 28:09Speaker 2: but for real apps you implement the user detail service.
- 28:12Speaker 1: Interface and that talks to my database.
- 28:14Speaker 2: Typically, yes, you'd inject your user repository into your custom
- 28:18Speaker 2: user detail service implementation to load user details. Spring security
- 28:22Speaker 2: then uses a DEO authentication provider to check passwords against
- 28:26Speaker 2: what your service.
- 28:26Speaker 1: Returns, and you configure log in methods like form log in.
- 28:30Speaker 2: Yeah. Using the HTDP security Configuration object, you call methods
- 28:33Speaker 2: like HTTP basic or form log in to enable those mechanisms.
- 28:38Speaker 2: You also configure authorization rules there, like request matchers, admin
- 28:42Speaker 2: dot has role adm an.
- 28:45Speaker 1: What about cores? That's always tricky.
- 28:47Speaker 2: With front ends trucial, you can figure cores using a
- 28:50Speaker 2: course configuration source being usually within your security configuration to
- 28:54Speaker 2: allow requests from your front ends.
- 28:55Speaker 1: Origin and reactive security.
- 28:57Speaker 2: For web flex it's similar conceptually, but uses re active types.
- 29:00Speaker 2: You can figure server HTTP security instead of HTTP security,
- 29:04Speaker 2: and things like login handlers use reactive interfaces like server
- 29:07Speaker 2: authentication success handler.
- 29:08Speaker 1: Can I test security rules easily without doing a full
- 29:11Speaker 1: log in and every test?
- 29:12Speaker 2: Yes. The atwith mock user annotation is perfect for this.
- 29:16Speaker 2: You can apply it to your at webmvictest or at webflux.
- 29:19Speaker 2: Test methods to simulate a request coming from an already
- 29:22Speaker 2: authenticated user with specific roles saves a ton of setup.
- 29:26Speaker 1: Very handy. What about social login OOF two with GitHub.
- 29:29Speaker 2: Or Google also well supported? Add Spring Bootstarter O two client.
- 29:34Speaker 2: You can figure your client ID in secret from the provider,
- 29:37Speaker 2: use environment variables or secrets management, never hardcode them. Spring
- 29:40Speaker 2: Security handles the whole redirect dance and authentication flow smooth.
- 29:44Speaker 1: The book also mentions Spring Authorization Server. What's that? Why
- 29:47Speaker 1: would I run my own authorization server?
- 29:48Speaker 2: That's for when you want to be the identity provider,
- 29:50Speaker 2: maybe for your own suite of micro services or partner applications.
- 29:54Speaker 2: Spring Authorization Server is a dedicated project providing a compliant
- 29:58Speaker 2: OOF two point one and open id Connect one point
- 30:02Speaker 2: zero server implementation built on Spring Security. You can figure
- 30:05Speaker 2: clients scopes like users, dot red, token, settings, etc. Gives
- 30:10Speaker 2: you full control over the identity aspect.
- 30:12Speaker 1: Okay, so full spectrum of security. Let's shift to performance
- 30:15Speaker 1: and deployment Spring boot native and AOT with galvim. What's
- 30:20Speaker 1: the big deal with GraalVM.
- 30:21Speaker 2: Galvm is a high performance JDK distribution key features are
- 30:26Speaker 2: faster JIT compilation, support for multiple languages, and most importantly
- 30:31Speaker 2: for this discussion, its native image capability.
- 30:34Speaker 1: Native image What does that actually mean for my app?
- 30:37Speaker 2: It means compiling your Java Cottlin code ahead of time
- 30:40Speaker 2: AOT into a standalone native executable for a specific platform
- 30:44Speaker 2: like Linux by sixty four. This executable does not require
- 30:48Speaker 2: a JVM to run.
- 30:49Speaker 1: No JVM. What's the benefit?
- 30:50Speaker 2: Huge benefits. Drastically faster startup times think milliseconds instead of seconds,
- 30:55Speaker 2: and significantly lower memory footprint, maybe tens of megabytes instead
- 30:59Speaker 2: of hundreds. It's the game changer for serverless functions, containers
- 31:02Speaker 2: anywhere resources or startup speed matter.
- 31:04Speaker 1: That is a massive difference. How do you build one
- 31:06Speaker 1: with Springboot?
- 31:07Speaker 2: Typically using the build tool plugins like Doug gritlue Boot
- 31:10Speaker 2: build Image or the Maven equivalent. This often uses cloud
- 31:13Speaker 2: native build packs behind the scenes to perform the native
- 31:15Speaker 2: compilation inside a container and package the result.
- 31:18Speaker 1: And what spring boots specific role the AOT part exactly.
- 31:22Speaker 2: The standard Java reflection and dynamic proxies that spring uses
- 31:26Speaker 2: heavily are difficult for grailvm's static analysis, so spring boots
- 31:30Speaker 2: AOT engine runs at build time, analyzes your application context
- 31:35Speaker 2: figures out what beams, proxies and configurations will be needed
- 31:38Speaker 2: at runtime, and generates extra source code and hints.
- 31:41Speaker 1: So it pre computes the runtime configuration essentially.
- 31:44Speaker 2: Yes, it generates code that GRAILVM can analyze statically, allowing
- 31:48Speaker 2: the native compilation to succeed while preserving Springs functionality.
- 31:52Speaker 1: What if my code does something really dynamic, like reflection
- 31:56Speaker 1: that the AOT engine misses.
- 31:57Speaker 2: That's where you need runtime hints. Can implement a runtime
- 32:01Speaker 2: hints registrar interface to programmatically tell the AOT engine about
- 32:04Speaker 2: specific reflection needs, resource loading, serialization, or proxy requirements that
- 32:10Speaker 2: it couldn't detect automatically.
- 32:11Speaker 1: Okay, so native images offer huge performance games enabled by
- 32:14Speaker 1: Springs AOT processing. Now looming out to architecture spring Cloud
- 32:19Speaker 1: for microservices. How to boot and cloud fit together.
- 32:22Speaker 2: They're designed to work hand in glove. Springboot is perfect
- 32:25Speaker 2: for building the individual microservices self contained runnable jrs with
- 32:30Speaker 2: embedded servers. It aligns perfectly with those twelve factor app
- 32:34Speaker 2: principles needed for micro services.
- 32:36Speaker 1: Like codebase canfig dependencies processes exactly.
- 32:40Speaker 2: Springboot gives you the ideal building block. Spring Cloud then
- 32:44Speaker 2: provides the tools to handle the interactions and patterns needed
- 32:47Speaker 2: in a distributed microservice system.
- 32:49Speaker 1: And when we talk cloud development, it's more than just
- 32:51Speaker 1: deploying to AWS right.
- 32:53Speaker 2: It's about building applications natively for the cloud environment, leveraging elasticity,
- 32:57Speaker 2: fault tolerance, managed services, moving beyond just lifting and shifting
- 33:01Speaker 2: old apps to designing for the cloud from the start.
- 33:04Speaker 1: So what are some key spring Cloud technologies that help
- 33:06Speaker 1: manage this complexity?
- 33:08Speaker 2: Okay, several key ones. First, spring Cloud Console or Eureka
- 33:12Speaker 2: or Kubernety. Service discovery. It handles service registration and discovery.
- 33:16Speaker 2: Services register themselves and clients can dynamically find where other
- 33:20Speaker 2: services are running without hardcoding URLs. It can also manage
- 33:24Speaker 2: externalized configuration.
- 33:26Speaker 1: Essentral for dynamic environments.
- 33:27Speaker 2: What else spring Cloud open fame. This makes calling other
- 33:31Speaker 2: rest services incredibly easy. You just define a Java interface
- 33:35Speaker 2: with annotations and fine handles creating the HTTP client, doing
- 33:40Speaker 2: service discovery, client side load balancing. It feels like calling
- 33:45Speaker 2: a local method.
- 33:46Speaker 1: Nice abstraction. What about secrets, databased passwords, apikes?
- 33:50Speaker 2: Spring Cloud Vault. It integrates with how she co op
- 33:53Speaker 2: Vault or other secret managers to securely inject secrets into
- 33:57Speaker 2: your application and run time. No more secrets and properties,
- 34:00Speaker 2: files or environment variables. Volt handle secure storage, access control
- 34:04Speaker 2: and even secret.
- 34:05Speaker 1: Rotation critical for security. What about the entry point to
- 34:08Speaker 1: the whole system.
- 34:09Speaker 2: That's spring Cloud Gateway. It's an API gateway built on
- 34:12Speaker 2: spring webslucks, so it's reactive and non blocking. It provides
- 34:15Speaker 2: a single point of entry for all external requests. It
- 34:17Speaker 2: can handle routing, applying security filters like rate limiting or authentication,
- 34:22Speaker 2: load balancing, path rewriting, and implementing resilience patterns like circuit breaking.
- 34:27Speaker 1: Circuit breaks.
- 34:28Speaker 2: Yeah, if a downstream service starts failing, the gateway can
- 34:30Speaker 2: trip the circuit and stop setting request to it for
- 34:33Speaker 2: a while, preventing cascading failures and returning a fallback response instead.
- 34:38Speaker 1: Smart and finally, orchestrating all these containerized services Kubernetes absolutely.
- 34:43Speaker 2: Kubernetes k eights is the standard for container orchestration spring Cloud.
- 34:48Speaker 2: Kubernetes provides integrations spring Cloud Starter, Kuberneteses Client all so
- 34:53Speaker 2: your boot apps can seamlessly leverage K eight's features like
- 34:56Speaker 2: config maps for configuration, secrets for secrets management, and KAID
- 35:00Speaker 2: service discovery, all without much code change you deploy using
- 35:04Speaker 2: Kid's deployment and service ammal manifests.
- 35:07Speaker 1: So spring cloud provides the connective tissue for boot micro
- 35:10Speaker 1: services in a cloud environment. Okay, one more advanced topic,
- 35:13Speaker 1: extending boot itself with custom starters. Why bother creating your own?
- 35:17Speaker 2: The main reasons are speed, consistency, and maintainability within your
- 35:21Speaker 2: organization or team. If you have a common cross cutting
- 35:24Speaker 2: concern like specific auditing, security checks or client library setup,
- 35:28Speaker 2: you can package it as a starter.
- 35:30Speaker 1: So new projects just include your starter exactly.
- 35:33Speaker 2: They get all that boilerplate and configuration handled automatically, ensuring
- 35:36Speaker 2: everyone follows the same pattern. It reduces setup time, It
- 35:40Speaker 2: makes codebases more consistent and easier to maintain.
- 35:42Speaker 1: Is it like using spring zone at enable annotations at
- 35:45Speaker 1: enable web NBC at enable caching?
- 35:48Speaker 2: Very similar concept. Those annotations trigger auto configuration. You can
- 35:52Speaker 2: create your own custom that enable my feature annotation as
- 35:55Speaker 2: part of your starter to make it easy for users
- 35:57Speaker 2: to opt in to your functionality.
- 35:59Speaker 1: Declaratively, how are starters typically structured?
- 36:02Speaker 2: Usually as two modules. An autoconfigure module contains the core logic,
- 36:07Speaker 2: the at configuration or at autoconfiguration classes often conditional using
- 36:11Speaker 2: at conditional non annotations, any configuration properties, classes and the
- 36:16Speaker 2: logic itself like aspects or beans.
- 36:18Speaker 1: And the second module.
- 36:19Speaker 2: A starter module. This one's usually very simple. It just
- 36:22Speaker 2: declares dependencies on the autoconfigure module and any other third
- 36:26Speaker 2: party libraries. Your feature needs users, then just depend on
- 36:29Speaker 2: your my feature spring boots starter.
- 36:31Speaker 1: Can you give a quick example.
- 36:32Speaker 2: The book uses a my retroadit Starter example. It is
- 36:35Speaker 2: a custom in my retrodit annotation an aspect my retro
- 36:39Speaker 2: audit aspect uses at a round advice to intercept calls
- 36:43Speaker 2: to annotated methods and log ondit info, and the auto
- 36:45Speaker 2: configuration a my retroaddic configuration class marks at autoconfiguration conditionally
- 36:51Speaker 2: enables the aspect maybe based on a property or if
- 36:54Speaker 2: the custom at enable my retroad annotation is present, then
- 36:58Speaker 2: you register this autoconfiguration clas in the special meta and
- 37:02Speaker 2: f spring org dot, spring framework, dot boot, dot autoconfigure,
- 37:05Speaker 2: dot autoconfiguration dot imports.
- 37:07Speaker 1: File so it automatically wires up the auditing aspect if
- 37:09Speaker 1: the starter is included and enabled. Clever okay. Wrapping up
- 37:12Speaker 1: the book touches on some newer projects. What's exciting on
- 37:15Speaker 1: the horizon.
- 37:15Speaker 2: First, Spring modulith. This is interesting. It's not micro services,
- 37:19Speaker 2: but it helps structure larger spring Boot modulates into well
- 37:22Speaker 2: defined modules within the same.
- 37:23Speaker 1: Codebase, modularity inside the monolith exactly.
- 37:26Speaker 2: It helps enforce boundaries between modules, verifies dependencies of build time,
- 37:30Speaker 2: and can even generate diagrams of your module structure. It
- 37:34Speaker 2: encourages looser coupling, often through event driven communication between modules
- 37:38Speaker 2: instead of direct calls. It's about making monoliths more manageable,
- 37:42Speaker 2: a pragmatic approach. What else, Spring ai this is huge.
- 37:46Speaker 2: It's a new framework bringing AI capabilities, especially large language
- 37:50Speaker 2: models lms like GBT four directly into Spring applications.
- 37:54Speaker 1: Like Python's lang chain but for Java Spring.
- 37:57Speaker 2: Kind of yeah. It simplifies interacting with AIME models using
- 38:00Speaker 2: concepts like chat client prompt templates and handling embeddings numerical
- 38:05Speaker 2: representations of text for semantic understanding. Makes building AI powered
- 38:09Speaker 2: features in Spring much.
- 38:10Speaker 1: Easier, very cool and performance improvement.
- 38:13Speaker 2: Virtual threads from Jaba twenty one are now supported in
- 38:15Speaker 2: Spring Boot three point two plus okios. You just flip
- 38:18Speaker 2: a switch Spring dot threads dot virtual dot enable true
- 38:22Speaker 2: and tomcatter jety can start using lightweight virtual threads for
- 38:25Speaker 2: handling requests.
- 38:26Speaker 1: What's the benefit.
- 38:27Speaker 2: Potentially massive throughput improvements for iobound applications without complex ACYN
- 38:32Speaker 2: code because you can have millions of virtual threads with
- 38:35Speaker 2: very little overhead compared to traditional platform threads.
- 38:38Speaker 1: Wow, simple switch, big impact potentially. And finally, Graphql.
- 38:43Speaker 2: Yeah, graph L is gaining traction as an alternative to
- 38:46Speaker 2: rest It lets clients request exactly the data they need,
- 38:50Speaker 2: no more, no less, reducing overfetching. Spring for Graphql provides
- 38:55Speaker 2: excellent integration.
- 38:56Speaker 1: How does it work?
- 38:57Speaker 2: You define your API schema using GRAPHQOLS, Schema Definition Language
- 39:00Speaker 2: SDL and a dog graphcuels file. Then in your Spring
- 39:04Speaker 2: code you use annotations like at query mapping and at
- 39:07Speaker 2: mutation mapping on methods to implement the resolvers for your
- 39:10Speaker 2: schema fields. It also integrates with tools like graphuel for
- 39:13Speaker 2: interactive testing.
- 39:14Speaker 1: So a different way to build APIs fully supported. Wow. Okay,
- 39:18Speaker 1: we have covered a lot of ground here. It's been
- 39:19Speaker 1: a real deep dive, hasn't it.
- 39:21Speaker 2: Absolutely from the core ideas of autoconfiguration, right.
- 39:24Speaker 1: Through building web apps, data access messaging, then production stuff
- 39:27Speaker 1: like actuator testing, security.
- 39:29Speaker 2: Dative images. Spring Cloud for micro services even custom starters
- 39:34Speaker 2: and bleeding edge things like AI and virtual threads.
- 39:38Speaker 1: It really paints a picture of a comprehensive ecosystem.
- 39:41Speaker 2: It does. It's about enabling developers to build sophisticated systems
- 39:45Speaker 2: faster and more reliably, handling the boiler plate so you
- 39:48Speaker 2: can focus on the unique value.
- 39:50Speaker 1: So for you listening, what really stands out is how
- 39:53Speaker 1: Spring boot, with this whole rich ecosystem, acts like this
- 39:56Speaker 1: incredible orchestrator right. It lets you the developer, build complex
- 40:01Speaker 1: applications quickly without getting totally bogged down on the plumbing.
- 40:04Speaker 1: It empowers you to focus on your business logic. You
- 40:07Speaker 1: can really see how all these pieces from a simple
- 40:10Speaker 1: at rest controller to a full Kate's deployment fit together.
- 40:14Speaker 2: It gives you the tools and the patterns to build
- 40:16Speaker 2: modern software effectively.
- 40:18Speaker 1: And as we saw with things like Spring Modulus and
- 40:20Speaker 1: Spring AI, this whole landscape just keeps evolving, doesn't it.
- 40:23Speaker 1: So here's the thought to leave you with, what if
- 40:25Speaker 1: the next big leap isn't just about how services talk
- 40:28Speaker 1: to each other, but how entire applications, maybe modular ones
- 40:31Speaker 1: powered by AI can adapt and reconfigure themselves on the fly,
- 40:35Speaker 1: almost like biological systems. What new Aha moments are waiting
- 40:39Speaker 1: just around the corner in software architecture, Something to chew
- 40:42Speaker 1: on as you continue your own explorations in this fascinating world.