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
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
Lightning近況報告
kozy4324
0
220
MySQL & MySQL HeatWave Report - June 2026
freshdaz
0
110
Oracle Cloud Infrastructure:2026年6月度サービス・アップデート
oracle4engineer
PRO
0
290
Zenoh on Zephyr on LiteX
takasehideki
2
110
事業会社における 機械学習・推薦システム技術の活用事例と必要な能力 / ml-recsys-in-layerx-wantedly-2026
yuya4
0
160
從開發到部署全都交給 AI:實作 AI 驅動的自動化流程
appleboy
0
160
[チョークトーク資料]AWS DevOps Agent を使いこなす / AWS Dev Ops Agent Chalk Talk AWS Summit Japan 2026
kinunori
4
770
From Prompt Engineering to Loop Engineering
shibuiwilliam
1
180
現場のトークンマネジメント
dak2
1
190
Microsoft のサポートとフィードバック総まとめ
murachiakira
PRO
0
110
Kiro Ambassador を目指す話
k_adachi_01
0
130
2026 AI Memory Architecture
nagatsu
0
110
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
210k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.6k
Prompt Engineering for Job Search
mfonobong
0
350
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Code Reviewing Like a Champion
maltzj
528
40k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Un-Boring Meetings
codingconduct
0
320
Why Our Code Smells
bkeepers
PRO
340
58k
30 Presentation Tips
portentint
PRO
1
330
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
420
Into the Great Unknown - MozCon
thekraken
41
2.6k
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