Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Breaking the Magician's Code - Diving deeper in...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Phil Webb
February 28, 2017
Technology
2.1k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Breaking the Magician's Code - Diving deeper into Spring Boot internals
Presented @DevNexus '17
Phil Webb
February 28, 2017
More Decks by Phil Webb
See All by Phil Webb
Spring Boot for the Java EE Developer
philwebb
1
440
Behind the OSS curtain: How we manage Spring
philwebb
1
340
Keeping It Clean
philwebb
9
1k
Other Decks in Technology
See All in Technology
From Prompt Engineering to Loop Engineering
shibuiwilliam
1
170
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
860
Flow 不死:AI 時代 DevOps 的不變本質
cheng_wei_chen
2
500
感情と身体を置き去りにしない、エンジニアの生きのこり方 ──いまから、ここから「自分の状態」を扱うという選択
saorimurooka
0
330
気軽に使える"情報のハブ"としてのNotion活用 〜フロー情報の集積点 と、 Claude Code × Notion AI〜
syucream
1
180
起点・思考・出力で分解する 〜PM業務の自動化設計〜
kazu_kichi_67
1
1k
【セミナー資料】Claude Code をセキュアに使うための考え方と設定の勘どころ / Claude Code Webinar 20260616
masahirokawahara
2
460
2026 AI Memory Architecture
nagatsu
0
100
MUSUBI 田中裕一『AIと共に行う「しごとのリデザイン」- スモールバックオフィス編』AI Ops Lab #4
musubi
0
310
技術・能力を向上する原理原則 #きのこセッションa #きのこ2026
bash0c7
0
120
OTel × Datadog で 「AI活用」を計測し、改善に繋げる
shihochan
2
630
あなたの知らないPDFのアクセシビリティ
lycorptech_jp
PRO
0
240
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
My Coaching Mixtape
mlcsv
0
150
Embracing the Ebb and Flow
colly
88
5.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
610
Marketing to machines
jonoalderson
1
5.5k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
230
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Transcript
Breaking the Magician's Code Diving deeper into Spring Boot internals
@phillip_webb @madhurabhave23
None
DEMO start.spring.io
DEMO Starting from scratch
Embedded Servlet Container Tomcat WAR ServletContainerInitializer AbstractAnnotationConfigDispatcherServletInitializer WebApplicationContext Dispatcher Servlet
Embedded Servlet Container WebApplicationContext Embedded EmbeddedServletContainerFactory EmbeddedServletContainer getEmbeddedServletContainer( ServletContextInitializer... initializers);
EmbeddedServletContainer start() stop() getPort()
DEMO Back to the CODE
Servlets WebApplicationContext Embedded Servlet Filter ServletContextInitializer ServletRegistrationBean FilterRegistrationBean
Servlets WebApplicationContext Embedded Servlet DispatcherServlet @RequestMapping(“/foo”) @RequestMapping(“/bar”)
DEMO Back to the CODE
Component scanning • @Componentscan • base Packages • base Package
Classes • (default)
Component Scanning com.example.demo.core.* com.example.demo.domain.* com.example.demo.Application com.example.demo.config.*
Component Scanning example demo com config core domain
Component Scanning example demo com config core domain .Application
Component Scanning example demo com config core domain .Application
Component Scanning example demo com config core domain .Application
Component Scanning example demo com config core domain .Application
DEMO Back to the CODE
Meta-Annotations • Most Spring Annotations can be used as meta-annotations
• Use in your own code • Used extensively in the framework: •@RestController •@GetMapping
META-Annotations • @AliasFor for advanced mappings: @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan public
@interface SpringBootApplication { @AliasFor(annotation = EnableAutoConfiguration.class, attribute = "exclude") Class<?>[] exclude() default {}; @AliasFor(annotation = ComponentScan.class, attribute = "basePackages") String[] scanBasePackages() default {};
DEMO Back to the CODE
Advanced ImportS • @Import(Regular.class) • ImportSelector • Return String[] •
ImportBeanDefinitionRegistrar • Direct registration
Spring Factories • Dirt simple way to discover implementations •
Similar to Java Service Loader • Simple properties file • /META-INF/spring.factories
DEMO Back to the CODE
Conditions • @Conditional annotation • Condition interface public interface Condition
{ boolean matches( ConditionContext context, AnnotatedTypeMetadata metadata); }
Conditions • Spring Framework @Profile • Spring Boot (Bean,Class,Property) •
Ordered so fastest run first
DEMO Back to the CODE
Spring Boot Code •ConditionalOnAClass -> ConditionalOnClass • MagicApplication -> SpringBootApplication
• EnableMagicAutoConfiguration -> EnableAutoConfiguration • EnableMagicProperties -> EnableConfigurationProperties • *Configuration -> *AutoConfiguration
Summary • There’s no such thing as magic • Follow
the breadcrumbs • Annotations • Import Selectors • Spring Factories • Conditions • Use the source!
Thanks! Questions? @madhurabhave23 @phillip_webb speakerdeck.com/philwebb https://github.com/mbhave/non-magic-demo