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
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
460
Behind the OSS curtain: How we manage Spring
philwebb
1
350
Keeping It Clean
philwebb
9
1k
Other Decks in Technology
See All in Technology
Genie Code ワークショップ 基礎編 / Genie-Code-Workshop-fundamental
databricksjapan
PRO
0
330
Amazon S3 Tablesに全部任せてみた結果——コンパクション/スナップショット管理は本当に手放せるか
shigeruoda
0
320
Sony-DroidKaigi2026
sony
1
310
Self Healing Rollouts: Automating Production Fixes with Agentic AI
kdubois
0
140
Azure Cost Management の FOCUS コストデータを迷わず読むための“3つの軸”
tetsuyaooooo
0
140
Azure App Service / Container Apps の組み込み認証
kuniteru
0
190
全社に広がるMCPサーバーを、 どう安全に管理するか MCPass開発の舞台裏
mtpooh
3
280
分割40%キーボードにスムーズに入門するには
hoto17296
1
230
2026-09-04 SRE Tech Talk #15 怠惰なTerraform / Lazy Terraform
masasuzu
0
170
Genie Code ワークショップ 応用編 / Genie-Code-Workshop-advanced
databricksjapan
PRO
0
300
bet_ai_day_2026_session02
agenticsec
1
910
When Does a Local Qwen Start to Break
morshoto
0
160
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
590
Unsuck your backbone
ammeep
672
58k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
4
560
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.5k
Designing for Timeless Needs
cassininazir
1
470
4 Signs Your Business is Dying
shpigford
187
23k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
470
Making the Leap to Tech Lead
cromwellryan
135
10k
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