File tree 3 files changed +46
-1
lines changed
java/dev/nicklatcham/shopthing/config
3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 72
72
<groupId >org.springframework.boot</groupId >
73
73
<artifactId >spring-boot-maven-plugin</artifactId >
74
74
</plugin >
75
+ <plugin >
76
+ <groupId >org.apache.maven.plugins</groupId >
77
+ <artifactId >maven-compiler-plugin</artifactId >
78
+ <configuration >
79
+ <source >22</source >
80
+ <target >22</target >
81
+ <compilerArgs >
82
+ --enable-preview
83
+ </compilerArgs >
84
+ </configuration >
85
+ </plugin >
75
86
</plugins >
76
87
</build >
77
88
Original file line number Diff line number Diff line change
1
+ package dev .nicklatcham .shopthing .config ;
2
+
3
+ import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
4
+ import org .springframework .boot .web .embedded .tomcat .TomcatProtocolHandlerCustomizer ;
5
+ import org .springframework .context .annotation .Bean ;
6
+ import org .springframework .context .annotation .Configuration ;
7
+ import org .springframework .core .task .AsyncTaskExecutor ;
8
+ import org .springframework .core .task .support .TaskExecutorAdapter ;
9
+ import org .springframework .scheduling .annotation .EnableAsync ;
10
+ import java .util .concurrent .Executors ;
11
+
12
+ @ EnableAsync
13
+ @ Configuration
14
+ @ ConditionalOnProperty (
15
+ value = "spring.thread-executor" ,
16
+ havingValue = "virtual"
17
+ )
18
+ public class ThreadConfig {
19
+
20
+ @ Bean
21
+ public AsyncTaskExecutor applicationTaskExecutor () {
22
+ return new TaskExecutorAdapter (Executors .newVirtualThreadPerTaskExecutor ());
23
+ }
24
+
25
+ @ Bean
26
+ public TomcatProtocolHandlerCustomizer <?> protocolHandlerVirtualThreadExecutorCustomizer () {
27
+ return protocolHandler -> {
28
+ protocolHandler .setExecutor (Executors .newVirtualThreadPerTaskExecutor ());
29
+ };
30
+ }
31
+ }
Original file line number Diff line number Diff line change 1
1
spring.application.name =shopthing
2
- spring.datasource.url =jdbc:h2:mem:shopthingdev
2
+ spring.datasource.url =jdbc:h2:mem:shopthingdev
3
+
4
+ spring.threads.virtual.enabled =true
5
+ spring.thread-executor =virtual
You can’t perform that action at this time.
0 commit comments