SlideShare a Scribd company logo
1 of 94
Download to read offline
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3 1
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
2
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 

3
基礎を固めよ!
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
4
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
5
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
6
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
▸
▸
7
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
8
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
▸
▸
9
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
10
Spring Web 4 Spring MVC
Spring Boot Developer 2 Spring Boot
Spring Cloud Services
3
( )
Spring Cloud Microservices
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
11
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
12
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
13
Spring Framework
Spring Boot
Spring Cloud
Data, Security, Batch, …
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
14
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
15
※CoC : Convention over Configuration ( )







Seasar2 Ruby on Rails
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸


▸
16
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
17
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
18
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
▸
▸
19
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
20
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 

@Component
21
package	hoge.service.impl;	
@Component	
public	class	FooServiceImpl	
								implements	FooService	{	
		//	 	
}
※ ( FooService)
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ @Configuration 

@ComponentScan
22
package	hoge.config;	
@Configuration	
@ComponentScan(basePackages	=	{	
		“hoge.service.impl”})	
public	class	AppConfig	{	
		//	 OK	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ basePackages
@Component
23
hoge
config
service
impl
bar
App	
Config
FooService	
Impl
Bar
FooService


(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ AnnotationConfigApplicationContext 

▸ ApplicationContext
24
//	 	
//	 	
ApplicationContext	context	=		
		new	AnnotationConfigApplicationContext(	
				AppConfig.class);
※ Java Config
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸ getBean()
25
ApplicationContext	context	=	…;	
FooService	fs	=	
		context.getBean(FooService.class);
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
26
@Component	//	 	
public	class	FooController	{	
		private	final	FooService	fs;	//	 	
			
		@Autowired	//	 	
		public	FooController(FooService	fs)	{	
				this.fs	=	fs;	
		}}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ @Bean 

27
@Configuration	//	@ComponentScan 	
public	class	AppConfig2	{	
		@Bean	
		public	BarService	barService()	{	
						//	 	
				return	new	BarServiceImpl();	
		}	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ @Bean
28
@Configuration	
public	class	AppConfig3	{	
		@Bean	
		public	BarService	barService(	
																	BarRepository	br)	{	
				return	new	BarServiceImpl(br);	
		}	
}


Bean 

(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ @Component
29
ApplicationContext	context	=		
		new	AnnotationConfigApplicationContext(	
				AppConfig2.class);	
BarService	bs	=	context.getBean(BarService.class);
@Component	
public	class	BarController	{	
		private	final	BarService	bs;	
			
		@Autowired	//	 	
		public	BarController(BarService	bs)	{	
				this.bs	=	bs;	
		}	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 	
▸ @Bean
▸ basePackages @Component
30
@Configuration	
@ComponentScan(basePackages	=		
		“hoge.service.impl”)	
public	class	AppConfig4	{	
		@Bean	
		public	BarService	barService()	{	
				return	new	BarServiceImpl();	
		}	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸ @Component
▸ @Bean
31
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
32
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
33
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
34


View	
Resolver ※ 

Spring Spring 

Dispatcher

Servlet
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
DispatcherServlet
▸
▸
WebApplicationInitialzer
▸
▸
35
Dispatcher

Servlet
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 

▸
▸ 

DispatcherServlet
36
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
ViewResolver
▸
▸ ”employee/index”

”/WEB-INF/views/employee/index.jsp”
▸
▸ InternalResourceViewResolver	
▸ ThymeleafViewReseolver	
▸ FreeMarkerViewResolver	
37
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
ViewResolver
38
@Configuration	
public	class	MvcConfig	…	{	
		@Bean	
		public	InternalResourceViewResolver		
								viewResolver()	{	
				InternalResourceViewResolver	vr	=		
						new	InternalResourceViewResolver();	
				vr.setPrefix("/WEB-INF/views/");	
				vr.setSuffix(".jsp");	
				return	vr;	
		}	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
ViewResolver
▸ DispatcherServlet ViewResolver
39
https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/java/org/springframework/web/servlet/
DispatcherServlet.java#L733
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 

ViewResolver
▸
▸
▸
▸
40
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 

ViewResolver
▸
▸
▸
▸
41
@EnableWebMvc
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
@EnableWebMvc
▸ @Import
▸
▸ @EnableXxx 

42
https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/java/org/
springframework/web/servlet/config/annotation/EnableWebMvc.java#L101
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ @Controller
▸ @Component
43
package	hoge.controller	
@Controller	
@RequestMapping(“/employee”)	
public	class	EmployeeController	{	
		@GetMapping(“/index”)	
		public	String	index()	{	
				return	“employee/index”;	
		}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ @Component 	
▸ @Controller	
▸ @RestController	
▸ @Configuration	👈 	
▸ @Service	
▸ @Repository	
44
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
45
@ComponentScan(basePackages	=		
				“hoge.controller”)	
@Configuration	
public	class	MvcConfig	{	
		…	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
46
@EnableWebMvc	
@ComponentScan(basePackages	=		
				“hoge.controller”)	
@Configuration	
public	class	MvcConfig	…	{	
		@Bean	
		public	InternalResourceViewResolver		
								viewResolver()	{	
				…	
		}	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
47
DispatcherServlet
ViewResolver

Bean


Bean


Bean


Bean
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ DispatcherServlet 

▸ 

	
▸ @EnableWebMvc 	
▸ @Controller @ComponentScan 

48
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸ 

▸
▸
49
https://www.casareal.co.jp/recruit/jobs/
ls_teacher.php
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 

✕ 

✕
▸ 







50
https://www.casareal.co.jp/ls/service/shinjinseminar/course01
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
51
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
52
ViewResolver

Bean


Bean
DataSource

Bean


Bean


Bean


Bean


Bean


Bean
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
53
ViewResolver

Bean


Bean
DataSource

Bean


Bean


Bean


Bean


Bean


Bean
Bean


Bean
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
54
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
55
@Configuration	
public	class	ThymeleafAutoConfiguration	{	
		…	
		@Configuration	
		public	static	class	XxxConfiguration	{	
				@Bean	
				public	ThymeleafViewResolver	
								thymeleafViewResolver()	{	
						…	
				}	
				…	
※static Java Config 

ViewResolver 

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/
springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L183
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
▸
▸
56
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 

▸
▸
▸
▸
57
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
@ConfigurationProperties
▸
58
@ConfigurationProperties(prefix	=	“spring.thymeleaf”)	
public	class	ThymeleafProperties	{	
		…	
		private	Charset	encoding	=	DEFAULT_ENCODING;	
		private	boolean	cache	=	true;	
		//	 	
}
spring.thymeleaf.encoding=Shift_JIS	
spring.thymeleaf.cache=false
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/
springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
@EnableConfigurationProperties
▸ @ConfigurationProperties
▸ @Component/@Bean
59
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/
springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L74
@EnableConfigurationProperties(	
				ThymeleafProperties.class)	
@Configuration	
public	class	ThymeleafAutoConfiguration	{	
		…
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸ 

	
▸ @ConfigurationProperties
60
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
61
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
62
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
63
@SpringBootApplication	
public	class	SampleApplication	{	
		public	static	void	main(String[]	args)	{	
				SpringApplication.run(	
								SampleApplication.class);	
		}	
}
@EnableAutoConfiguration	
@Configuration	
@ComponentScan	
public	@interface		
				SpringBootApplication	{	…
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
64
@EnableAutoConfiguration
org.springframework.boot.autoconfigure.EnableAutoCon
figuration=	
org.springframework.boot.autoconfigure.admin.SpringA
pplicationAdminJmxAutoConfiguration,	
org.springframework.boot.autoconfigure.aop.AopAutoCo
nfiguration,	
org.springframework.boot.autoconfigure.amqp.RabbitAu
toConfiguration,	
…


AutoConfiguration 

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/
resources/META-INF/spring.factories


(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
65
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 

▸
▸ 

66
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
@ConditionalOnXxx
▸ @Bean
▸
67
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
ThymeleafAutoConfiguration
68
@Configuration	
@ConditionalOnClass(TemplateMode.class) 	
@AutoConfigureAfter({WebMvcAutoConfiguration.class,	…	})	
public	class	ThymeleafAutoConfiguration	{	
		…	
		@Configuration	
		@ConditionalOnWebApplication(…)	
		public	static	class	XxxConfiguration	{	
				@Bean	
				@ConditionalOnMissingBean(	
								name	=	“thymeleafViewResolver”)	
				public	ThymeleafViewResolver	thymeleafViewResolver()	{	
						…
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/
springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L183
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
@ConditionalOnClass
▸
@ConditionalOnBean
▸
@ConditionalOnMissingBean
▸
69
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
@ConditionalOnProperty
▸
@ConditionalOnWebApplication
▸
@AutoConfigureAfter/@AutoConfigureBefore
▸
70
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ @EnableAutoConfiguration
▸ @ConditionalOnXxx
71
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
72
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
😭
@ConditionalOnMissingBean(Bean_1.class) 

@ConditionalOnBean(Bean_2.class) 

73
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
Spring Bootのべからず集
一.フレームワークを動かすBean
は、なるべく自前で定義する
べからず

二.@EnableXxxはなるべく付ける
べからず
74
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸ @EnableXxx
▸
▸
75
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3


76
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
77
https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
78
@Configuration	
public	class	SomeConfiguration	{	
		private	final	SomeBean	sb;	
		@Autowired	//	 		
		public	SomeConfiguration(SomeBean	sb)	{	
				this.sb	=	sb;	
		}	
		@PostConstruct	//	 	
		public	void	init()	{	
				sb.setXxx(…);	//	SomeBean 		
		}	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
79
@Configuration	
public	class	MyThymeleafConfiguration	{	
		@Bean	
		public	FooDialect	fooDialect()	{	
				return	new	FooDialect();	
		}	
		@Bean	
		public	BarDialect	barDialect()	{	
				return	new	BarDialect();	
		}	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ ThymeleafAutoConfiguration 

Dialect 

TemplateEngine Dialect
80
FooDialect

Bean
BarDialect

Bean
&Template

Engine

Bean &
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
81
@Configuration	
protected	static	class	ThymeleafDefaultConfiguration	{	
		//	Dialect Bean DI 	
		public	ThymeleafDefaultConfiguration(...,	
						ObjectProvider<Collection<IDialect>>	dProvider)	{	
				…	
		}	
			
		@Bean	
		public	SpringTemplateEngine	templateEngine()	{	
				SpringTemplateEngine	engine	=		
								new	SpringTemplateEngine();	
				//	Dialect 	
				this.dialects.forEach(engine::addDialect);	
				return	engine;	
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/
springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L140
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ XxxCustomizer
▸
▸
82
@FunctionalInterface	
public	interface	Jackson2ObjectMapperBuilderCustomizer	{	
	 void	customize(Jackson2ObjectMapperBuilder	builder);	
}
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/
springframework/boot/autoconfigure/jackson/Jackson2ObjectMapperBuilderCustomizer.java
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
83
@Configuration	
public	class	MyJacksonConfiguration	{	
		@Bean	
		public	Jackson2ObjectMapperBuilderCustomizer	
						jackson2ObjectMapperBuilderCustomizer()	{	
				//	 OK	
				return	builder	->	{	
						//	 	
						builder.modules(…)	
										.locale(…)	
										.indentOutput(…);	
				};	
		}	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
84
@Configuration	
static	class	JacksonObjectMapperBuilderConfiguration	{	
		@Bean	
		public	Jackson2ObjectMapperBuilder	…(	
				List<Jackson2ObjectMapperBuilderCustomizer>	
						customizers)	{	
				Jackson2ObjectMapperBuilder	builder	=		
								new	Jackson2ObjectMapperBuilder();	
				for	(Jackson2ObjectMapperBuilderCustomizer	
													customizer	:	customizers)	{	
						customizer.customize(builder);	
				}	
				return	builder;	
		}	
}
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/
springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java#L172
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ FilterRegistrationBean
85
@Bean	
public	FilterRegistrationBean	myFilter()	{	
		MyFilter	filter	=	new	MyFilter();	
		FilterRegistrationBean	frb	=		
						new	FilterRegistrationBean(filter);	
		//	 url-pattern	
		frb.addUrlPatterns(“/*”);	
		//	 	
		frb.setOrder(Ordered.HIGHEST_PRECEDENCE	+	10);	
		return	frb;	
}
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
▸
86
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
87
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
▸
88
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
89
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
▸
▸
90
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
▸
▸
▸
▸
▸
▸ 

91
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸ 😡
▸
▸ 



92
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
▸
93
(C) CASAREAL, Inc. All rights reserved.
#jjug #ccc_ef3
▸
94

More Related Content

What's hot

LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall )
LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall ) LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall )
LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall )
Hironobu Isoda
 
Junitを使ったjavaのテスト入門
Junitを使ったjavaのテスト入門Junitを使ったjavaのテスト入門
Junitを使ったjavaのテスト入門
Satoshi Kubo
 

What's hot (20)

Java ORマッパー選定のポイント #jsug
Java ORマッパー選定のポイント #jsugJava ORマッパー選定のポイント #jsug
Java ORマッパー選定のポイント #jsug
 
入社1年目のプログラミング初心者がSpringを学ぶための手引き
入社1年目のプログラミング初心者がSpringを学ぶための手引き入社1年目のプログラミング初心者がSpringを学ぶための手引き
入社1年目のプログラミング初心者がSpringを学ぶための手引き
 
Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方
 
ツール比較しながら語る O/RマッパーとDBマイグレーションの実際のところ
ツール比較しながら語る O/RマッパーとDBマイグレーションの実際のところツール比較しながら語る O/RマッパーとDBマイグレーションの実際のところ
ツール比較しながら語る O/RマッパーとDBマイグレーションの実際のところ
 
Spring超入門-Springと出会ってから1年半-
Spring超入門-Springと出会ってから1年半-Spring超入門-Springと出会ってから1年半-
Spring超入門-Springと出会ってから1年半-
 
これから始めるSpringのwebアプリケーション
これから始めるSpringのwebアプリケーションこれから始めるSpringのwebアプリケーション
これから始めるSpringのwebアプリケーション
 
決済サービスのSpring Bootのバージョンを2系に上げた話
決済サービスのSpring Bootのバージョンを2系に上げた話決済サービスのSpring Bootのバージョンを2系に上げた話
決済サービスのSpring Bootのバージョンを2系に上げた話
 
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
より速く より運用しやすく 進化し続けるJVM(Java Developers Summit Online 2023 発表資料)
 
LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall )
LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall ) LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall )
LogbackからLog4j 2への移行によるアプリケーションのスループット改善 ( JJUG CCC 2021 Fall )
 
Springを何となく使ってる人が抑えるべきポイント
Springを何となく使ってる人が抑えるべきポイントSpringを何となく使ってる人が抑えるべきポイント
Springを何となく使ってる人が抑えるべきポイント
 
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
今こそ知りたいSpring Batch(Spring Fest 2020講演資料)
 
Spring Data JPAによるデータアクセス徹底入門 #jsug
Spring Data JPAによるデータアクセス徹底入門 #jsugSpring Data JPAによるデータアクセス徹底入門 #jsug
Spring Data JPAによるデータアクセス徹底入門 #jsug
 
Spring Boot × Vue.jsでSPAを作る
Spring Boot × Vue.jsでSPAを作るSpring Boot × Vue.jsでSPAを作る
Spring Boot × Vue.jsでSPAを作る
 
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
OpenAPI 3.0でmicroserviceのAPI定義を試みてハマった話
 
世界一わかりやすいClean Architecture
世界一わかりやすいClean Architecture世界一わかりやすいClean Architecture
世界一わかりやすいClean Architecture
 
Spring Bootをはじめる時にやるべき10のこと
Spring Bootをはじめる時にやるべき10のことSpring Bootをはじめる時にやるべき10のこと
Spring Bootをはじめる時にやるべき10のこと
 
さくっと理解するSpring bootの仕組み
さくっと理解するSpring bootの仕組みさくっと理解するSpring bootの仕組み
さくっと理解するSpring bootの仕組み
 
Junitを使ったjavaのテスト入門
Junitを使ったjavaのテスト入門Junitを使ったjavaのテスト入門
Junitを使ったjavaのテスト入門
 
What's new in Spring Batch 5
What's new in Spring Batch 5What's new in Spring Batch 5
What's new in Spring Batch 5
 
今さら聞けないDiとspring
今さら聞けないDiとspring今さら聞けないDiとspring
今さら聞けないDiとspring
 

Viewers also liked

ユニットテストのアサーション 流れるようなインターフェースのAssertJを添えて 入門者仕立て
ユニットテストのアサーション 流れるようなインターフェースのAssertJを添えて 入門者仕立てユニットテストのアサーション 流れるようなインターフェースのAssertJを添えて 入門者仕立て
ユニットテストのアサーション 流れるようなインターフェースのAssertJを添えて 入門者仕立て
Ryosuke Uchitate
 
マルチクラウドデータ連携Javaアプリケーションの作り方
マルチクラウドデータ連携Javaアプリケーションの作り方マルチクラウドデータ連携Javaアプリケーションの作り方
マルチクラウドデータ連携Javaアプリケーションの作り方
CData Software Japan
 

Viewers also liked (20)

Java SE 9の紹介: モジュール・システムを中心に
Java SE 9の紹介: モジュール・システムを中心にJava SE 9の紹介: モジュール・システムを中心に
Java SE 9の紹介: モジュール・システムを中心に
 
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話DDD x CQRS   更新系と参照系で異なるORMを併用して上手くいった話
DDD x CQRS 更新系と参照系で異なるORMを併用して上手くいった話
 
劇的改善 Ci4時間から5分へ〜私がやった10のこと〜
劇的改善 Ci4時間から5分へ〜私がやった10のこと〜劇的改善 Ci4時間から5分へ〜私がやった10のこと〜
劇的改善 Ci4時間から5分へ〜私がやった10のこと〜
 
JJUG初心者のためのJava/JJUG講座
JJUG初心者のためのJava/JJUG講座JJUG初心者のためのJava/JJUG講座
JJUG初心者のためのJava/JJUG講座
 
Java9を迎えた今こそ!Java本格(再)入門
Java9を迎えた今こそ!Java本格(再)入門Java9を迎えた今こそ!Java本格(再)入門
Java9を迎えた今こそ!Java本格(再)入門
 
ユニットテストのアサーション 流れるようなインターフェースのAssertJを添えて 入門者仕立て
ユニットテストのアサーション 流れるようなインターフェースのAssertJを添えて 入門者仕立てユニットテストのアサーション 流れるようなインターフェースのAssertJを添えて 入門者仕立て
ユニットテストのアサーション 流れるようなインターフェースのAssertJを添えて 入門者仕立て
 
Dockerで始める Java EE アプリケーション開発 for JJUG CCC 2017
Dockerで始める Java EE アプリケーション開発 for JJUG CCC 2017Dockerで始める Java EE アプリケーション開発 for JJUG CCC 2017
Dockerで始める Java EE アプリケーション開発 for JJUG CCC 2017
 
サーバサイド Kotlin
サーバサイド Kotlinサーバサイド Kotlin
サーバサイド Kotlin
 
JVM上で動くPython処理系実装のススメ
JVM上で動くPython処理系実装のススメJVM上で動くPython処理系実装のススメ
JVM上で動くPython処理系実装のススメ
 
Business Process Modeling in Goldman Sachs @ JJUG CCC Fall 2017
Business Process Modeling in Goldman Sachs @ JJUG CCC Fall 2017Business Process Modeling in Goldman Sachs @ JJUG CCC Fall 2017
Business Process Modeling in Goldman Sachs @ JJUG CCC Fall 2017
 
JEP280: Java 9 で文字列結合の処理が変わるぞ!準備はいいか!? #jjug_ccc
JEP280: Java 9 で文字列結合の処理が変わるぞ!準備はいいか!? #jjug_cccJEP280: Java 9 で文字列結合の処理が変わるぞ!準備はいいか!? #jjug_ccc
JEP280: Java 9 で文字列結合の処理が変わるぞ!準備はいいか!? #jjug_ccc
 
Selenide or Geb 〜あなたはその時どちらを使う〜
Selenide or Geb 〜あなたはその時どちらを使う〜Selenide or Geb 〜あなたはその時どちらを使う〜
Selenide or Geb 〜あなたはその時どちらを使う〜
 
Javaアプリケーションの モダナイゼーションアプローチ
Javaアプリケーションの モダナイゼーションアプローチJavaアプリケーションの モダナイゼーションアプローチ
Javaアプリケーションの モダナイゼーションアプローチ
 
Redmine4時代のプラグイン開発 redmine.tokyo #13
Redmine4時代のプラグイン開発 redmine.tokyo #13Redmine4時代のプラグイン開発 redmine.tokyo #13
Redmine4時代のプラグイン開発 redmine.tokyo #13
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with Thymeleaf
 
マルチクラウドデータ連携Javaアプリケーションの作り方
マルチクラウドデータ連携Javaアプリケーションの作り方マルチクラウドデータ連携Javaアプリケーションの作り方
マルチクラウドデータ連携Javaアプリケーションの作り方
 
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方
サンプルアプリケーションで学ぶApache Cassandraを使ったJavaアプリケーションの作り方
 
高速なソートアルゴリズムを書こう!!
高速なソートアルゴリズムを書こう!!高速なソートアルゴリズムを書こう!!
高速なソートアルゴリズムを書こう!!
 
Open Liberty: オープンソースになったWebSphere Liberty
Open Liberty: オープンソースになったWebSphere LibertyOpen Liberty: オープンソースになったWebSphere Liberty
Open Liberty: オープンソースになったWebSphere Liberty
 
Another compilation method in java - AOT (Ahead of Time) compilation
Another compilation method in java - AOT (Ahead of Time) compilationAnother compilation method in java - AOT (Ahead of Time) compilation
Another compilation method in java - AOT (Ahead of Time) compilation
 

More from Masatoshi Tada

ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
Masatoshi Tada
 
JPAの同時実行制御とロック20140518 #ccc_r15 #jjug_ccc
JPAの同時実行制御とロック20140518 #ccc_r15 #jjug_cccJPAの同時実行制御とロック20140518 #ccc_r15 #jjug_ccc
JPAの同時実行制御とロック20140518 #ccc_r15 #jjug_ccc
Masatoshi Tada
 

More from Masatoshi Tada (11)

基礎からのOAuth 2.0とSpring Security 5.1による実装
基礎からのOAuth 2.0とSpring Security 5.1による実装基礎からのOAuth 2.0とSpring Security 5.1による実装
基礎からのOAuth 2.0とSpring Security 5.1による実装
 
Java EE 8新機能解説 -Bean Validation 2.0編-
Java EE 8新機能解説 -Bean Validation 2.0編-Java EE 8新機能解説 -Bean Validation 2.0編-
Java EE 8新機能解説 -Bean Validation 2.0編-
 
JSUG SpringOne 2017報告会
JSUG SpringOne 2017報告会JSUG SpringOne 2017報告会
JSUG SpringOne 2017報告会
 
とにかく分かりづらいTwelve-Factor Appの解説を試みる
とにかく分かりづらいTwelve-Factor Appの解説を試みるとにかく分かりづらいTwelve-Factor Appの解説を試みる
とにかく分かりづらいTwelve-Factor Appの解説を試みる
 
Java EEでもOAuth 2.0!~そしてPayara Micro on Cloud Foundryで遊ぶ~
Java EEでもOAuth 2.0!~そしてPayara Micro on Cloud Foundryで遊ぶ~Java EEでもOAuth 2.0!~そしてPayara Micro on Cloud Foundryで遊ぶ~
Java EEでもOAuth 2.0!~そしてPayara Micro on Cloud Foundryで遊ぶ~
 
Java EEハンズオン資料 JJUG CCC 2015 Fall
Java EEハンズオン資料 JJUG CCC 2015 FallJava EEハンズオン資料 JJUG CCC 2015 Fall
Java EEハンズオン資料 JJUG CCC 2015 Fall
 
Java EE 8先取り!MVC 1.0入門 [EDR2対応版] 2015-10-10更新
Java EE 8先取り!MVC 1.0入門 [EDR2対応版] 2015-10-10更新Java EE 8先取り!MVC 1.0入門 [EDR2対応版] 2015-10-10更新
Java EE 8先取り!MVC 1.0入門 [EDR2対応版] 2015-10-10更新
 
はまる!JPA(初学者向けライト版)
はまる!JPA(初学者向けライト版)はまる!JPA(初学者向けライト版)
はまる!JPA(初学者向けライト版)
 
NetBeansでかんたんJava EE ○分間クッキング! #kuwaccho lt
NetBeansでかんたんJava EE ○分間クッキング! #kuwaccho ltNetBeansでかんたんJava EE ○分間クッキング! #kuwaccho lt
NetBeansでかんたんJava EE ○分間クッキング! #kuwaccho lt
 
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
ステップ・バイ・ステップで学ぶラムダ式・Stream api入門 #jjug ccc #ccc h2
 
JPAの同時実行制御とロック20140518 #ccc_r15 #jjug_ccc
JPAの同時実行制御とロック20140518 #ccc_r15 #jjug_cccJPAの同時実行制御とロック20140518 #ccc_r15 #jjug_ccc
JPAの同時実行制御とロック20140518 #ccc_r15 #jjug_ccc
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Spring Bootの本当の理解ポイント #jjug

  • 1. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 1
  • 2. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 2
  • 3. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 
 3 基礎を固めよ!
  • 4. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ 4
  • 5. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ 5
  • 6. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 6
  • 7. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ ▸ ▸ 7
  • 8. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 8
  • 9. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ ▸ ▸ 9
  • 10. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 10 Spring Web 4 Spring MVC Spring Boot Developer 2 Spring Boot Spring Cloud Services 3 ( ) Spring Cloud Microservices
  • 11. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ 11
  • 12. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 12
  • 13. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 13 Spring Framework Spring Boot Spring Cloud Data, Security, Batch, …
  • 14. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ 14
  • 15. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ 15 ※CoC : Convention over Configuration ( )
 
 
 
 Seasar2 Ruby on Rails
  • 16. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 
 ▸ 16
  • 17. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 17
  • 18. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 18
  • 19. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ ▸ ▸ 19
  • 20. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 20
  • 21. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 
 @Component 21 package hoge.service.impl; @Component public class FooServiceImpl implements FooService { // } ※ ( FooService)
  • 22. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ @Configuration 
 @ComponentScan 22 package hoge.config; @Configuration @ComponentScan(basePackages = { “hoge.service.impl”}) public class AppConfig { // OK }
  • 23. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ basePackages @Component 23 hoge config service impl bar App Config FooService Impl Bar FooService 

  • 24. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ AnnotationConfigApplicationContext 
 ▸ ApplicationContext 24 // // ApplicationContext context = new AnnotationConfigApplicationContext( AppConfig.class); ※ Java Config
  • 25. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ getBean() 25 ApplicationContext context = …; FooService fs = context.getBean(FooService.class);
  • 26. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 26 @Component // public class FooController { private final FooService fs; // @Autowired // public FooController(FooService fs) { this.fs = fs; }}
  • 27. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ @Bean 
 27 @Configuration // @ComponentScan public class AppConfig2 { @Bean public BarService barService() { // return new BarServiceImpl(); } }
  • 28. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ @Bean 28 @Configuration public class AppConfig3 { @Bean public BarService barService( BarRepository br) { return new BarServiceImpl(br); } } 
 Bean 

  • 29. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ @Component 29 ApplicationContext context = new AnnotationConfigApplicationContext( AppConfig2.class); BarService bs = context.getBean(BarService.class); @Component public class BarController { private final BarService bs; @Autowired // public BarController(BarService bs) { this.bs = bs; } }
  • 30. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ @Bean ▸ basePackages @Component 30 @Configuration @ComponentScan(basePackages = “hoge.service.impl”) public class AppConfig4 { @Bean public BarService barService() { return new BarServiceImpl(); } }
  • 31. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ @Component ▸ @Bean 31
  • 32. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 32
  • 33. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ 33
  • 34. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 34 
 View Resolver ※ 
 Spring Spring 
 Dispatcher
 Servlet
  • 35. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 DispatcherServlet ▸ ▸ WebApplicationInitialzer ▸ ▸ 35 Dispatcher
 Servlet
  • 36. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 
 ▸ ▸ 
 DispatcherServlet 36
  • 37. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ViewResolver ▸ ▸ ”employee/index”
 ”/WEB-INF/views/employee/index.jsp” ▸ ▸ InternalResourceViewResolver ▸ ThymeleafViewReseolver ▸ FreeMarkerViewResolver 37
  • 38. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ViewResolver 38 @Configuration public class MvcConfig … { @Bean public InternalResourceViewResolver viewResolver() { InternalResourceViewResolver vr = new InternalResourceViewResolver(); vr.setPrefix("/WEB-INF/views/"); vr.setSuffix(".jsp"); return vr; } }
  • 39. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ViewResolver ▸ DispatcherServlet ViewResolver 39 https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/java/org/springframework/web/servlet/ DispatcherServlet.java#L733
  • 40. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 
 ViewResolver ▸ ▸ ▸ ▸ 40
  • 41. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 
 ViewResolver ▸ ▸ ▸ ▸ 41 @EnableWebMvc
  • 42. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 @EnableWebMvc ▸ @Import ▸ ▸ @EnableXxx 
 42 https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/java/org/ springframework/web/servlet/config/annotation/EnableWebMvc.java#L101
  • 43. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ @Controller ▸ @Component 43 package hoge.controller @Controller @RequestMapping(“/employee”) public class EmployeeController { @GetMapping(“/index”) public String index() { return “employee/index”; }
  • 44. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ @Component ▸ @Controller ▸ @RestController ▸ @Configuration 👈 ▸ @Service ▸ @Repository 44
  • 45. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 45 @ComponentScan(basePackages = “hoge.controller”) @Configuration public class MvcConfig { … }
  • 46. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 46 @EnableWebMvc @ComponentScan(basePackages = “hoge.controller”) @Configuration public class MvcConfig … { @Bean public InternalResourceViewResolver viewResolver() { … } }
  • 47. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 47 DispatcherServlet ViewResolver
 Bean 
 Bean 
 Bean 
 Bean
  • 48. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ DispatcherServlet 
 ▸ 
 ▸ @EnableWebMvc ▸ @Controller @ComponentScan 
 48
  • 49. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ 
 ▸ ▸ 49 https://www.casareal.co.jp/recruit/jobs/ ls_teacher.php
  • 50. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 
 ✕ 
 ✕ ▸ 
 
 
 
 50 https://www.casareal.co.jp/ls/service/shinjinseminar/course01
  • 51. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 51
  • 52. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 52 ViewResolver
 Bean 
 Bean DataSource
 Bean 
 Bean 
 Bean 
 Bean 
 Bean 
 Bean
  • 53. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 53 ViewResolver
 Bean 
 Bean DataSource
 Bean 
 Bean 
 Bean 
 Bean 
 Bean 
 Bean Bean 
 Bean
  • 54. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 54
  • 55. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 55 @Configuration public class ThymeleafAutoConfiguration { … @Configuration public static class XxxConfiguration { @Bean public ThymeleafViewResolver thymeleafViewResolver() { … } … ※static Java Config 
 ViewResolver 
 https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/ springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L183
  • 56. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ ▸ ▸ 56
  • 57. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 
 ▸ ▸ ▸ ▸ 57
  • 58. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 @ConfigurationProperties ▸ 58 @ConfigurationProperties(prefix = “spring.thymeleaf”) public class ThymeleafProperties { … private Charset encoding = DEFAULT_ENCODING; private boolean cache = true; // } spring.thymeleaf.encoding=Shift_JIS spring.thymeleaf.cache=false https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/ springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java
  • 59. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 @EnableConfigurationProperties ▸ @ConfigurationProperties ▸ @Component/@Bean 59 https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/ springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L74 @EnableConfigurationProperties( ThymeleafProperties.class) @Configuration public class ThymeleafAutoConfiguration { …
  • 60. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ 
 ▸ @ConfigurationProperties 60
  • 61. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 61
  • 62. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 62
  • 63. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 63 @SpringBootApplication public class SampleApplication { public static void main(String[] args) { SpringApplication.run( SampleApplication.class); } } @EnableAutoConfiguration @Configuration @ComponentScan public @interface SpringBootApplication { …
  • 64. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 64 @EnableAutoConfiguration org.springframework.boot.autoconfigure.EnableAutoCon figuration= org.springframework.boot.autoconfigure.admin.SpringA pplicationAdminJmxAutoConfiguration, org.springframework.boot.autoconfigure.aop.AopAutoCo nfiguration, org.springframework.boot.autoconfigure.amqp.RabbitAu toConfiguration, … 
 AutoConfiguration 
 https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/ resources/META-INF/spring.factories 

  • 65. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 65
  • 66. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 
 ▸ ▸ 
 66
  • 67. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 @ConditionalOnXxx ▸ @Bean ▸ 67
  • 68. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ThymeleafAutoConfiguration 68 @Configuration @ConditionalOnClass(TemplateMode.class) @AutoConfigureAfter({WebMvcAutoConfiguration.class, … }) public class ThymeleafAutoConfiguration { … @Configuration @ConditionalOnWebApplication(…) public static class XxxConfiguration { @Bean @ConditionalOnMissingBean( name = “thymeleafViewResolver”) public ThymeleafViewResolver thymeleafViewResolver() { … https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/ springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L183
  • 69. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 @ConditionalOnClass ▸ @ConditionalOnBean ▸ @ConditionalOnMissingBean ▸ 69
  • 70. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 @ConditionalOnProperty ▸ @ConditionalOnWebApplication ▸ @AutoConfigureAfter/@AutoConfigureBefore ▸ 70
  • 71. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ @EnableAutoConfiguration ▸ @ConditionalOnXxx 71
  • 72. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 72
  • 73. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 😭 @ConditionalOnMissingBean(Bean_1.class) 
 @ConditionalOnBean(Bean_2.class) 
 73
  • 74. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 Spring Bootのべからず集 一.フレームワークを動かすBean は、なるべく自前で定義する べからず 二.@EnableXxxはなるべく付ける べからず 74
  • 75. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ @EnableXxx ▸ ▸ 75
  • 76. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 
 76
  • 77. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 77 https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
  • 78. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 78 @Configuration public class SomeConfiguration { private final SomeBean sb; @Autowired // public SomeConfiguration(SomeBean sb) { this.sb = sb; } @PostConstruct // public void init() { sb.setXxx(…); // SomeBean } }
  • 79. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 79 @Configuration public class MyThymeleafConfiguration { @Bean public FooDialect fooDialect() { return new FooDialect(); } @Bean public BarDialect barDialect() { return new BarDialect(); } }
  • 80. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ThymeleafAutoConfiguration 
 Dialect 
 TemplateEngine Dialect 80 FooDialect
 Bean BarDialect
 Bean &Template
 Engine
 Bean &
  • 81. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 81 @Configuration protected static class ThymeleafDefaultConfiguration { // Dialect Bean DI public ThymeleafDefaultConfiguration(..., ObjectProvider<Collection<IDialect>> dProvider) { … } @Bean public SpringTemplateEngine templateEngine() { SpringTemplateEngine engine = new SpringTemplateEngine(); // Dialect this.dialects.forEach(engine::addDialect); return engine; https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/ springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java#L140
  • 82. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ XxxCustomizer ▸ ▸ 82 @FunctionalInterface public interface Jackson2ObjectMapperBuilderCustomizer { void customize(Jackson2ObjectMapperBuilder builder); } https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/ springframework/boot/autoconfigure/jackson/Jackson2ObjectMapperBuilderCustomizer.java
  • 83. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 83 @Configuration public class MyJacksonConfiguration { @Bean public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() { // OK return builder -> { // builder.modules(…) .locale(…) .indentOutput(…); }; } }
  • 84. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 84 @Configuration static class JacksonObjectMapperBuilderConfiguration { @Bean public Jackson2ObjectMapperBuilder …( List<Jackson2ObjectMapperBuilderCustomizer> customizers) { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder(); for (Jackson2ObjectMapperBuilderCustomizer customizer : customizers) { customizer.customize(builder); } return builder; } } https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/ springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java#L172
  • 85. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ FilterRegistrationBean 85 @Bean public FilterRegistrationBean myFilter() { MyFilter filter = new MyFilter(); FilterRegistrationBean frb = new FilterRegistrationBean(filter); // url-pattern frb.addUrlPatterns(“/*”); // frb.setOrder(Ordered.HIGHEST_PRECEDENCE + 10); return frb; }
  • 86. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ ▸ 86
  • 87. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 87
  • 88. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ ▸ 88
  • 89. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ 89
  • 90. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ ▸ ▸ 90
  • 91. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ ▸ ▸ ▸ ▸ ▸ ▸ 
 91
  • 92. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 😡 ▸ ▸ 
 
 92
  • 93. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ ▸ 93
  • 94. (C) CASAREAL, Inc. All rights reserved. #jjug #ccc_ef3 ▸ 94