Skip to content

Commit 890ee2d

Browse files
committed
fix: added missing main class to SpringApplicationBuilder (#1580)
fix: replaced `AnnotationConfigServletWebServerApplicationContext` with `ConfigurableWebApplicationContext` (#1580)
1 parent 4696691 commit 890ee2d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

aws-serverless-java-container-springboot3/src/main/java/com/amazonaws/serverless/proxy/spring/SpringBootLambdaContainerHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.slf4j.LoggerFactory;
1919
import org.springframework.boot.WebApplicationType;
2020
import org.springframework.boot.builder.SpringApplicationBuilder;
21-
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
21+
import org.springframework.web.context.ConfigurableWebApplicationContext;
2222
import org.springframework.context.ConfigurableApplicationContext;
2323

2424
import com.amazonaws.serverless.exceptions.ContainerInitializationException;
@@ -192,12 +192,15 @@ public void initialize()
192192

193193
SpringApplicationBuilder builder = new SpringApplicationBuilder(getEmbeddedContainerClasses())
194194
.web(springWebApplicationType); // .REACTIVE, .SERVLET
195+
if(springBootInitializer != null) {
196+
builder.main(springBootInitializer);
197+
}
195198
if (springProfiles != null) {
196199
builder.profiles(springProfiles);
197200
}
198201
applicationContext = builder.run();
199202
if (springWebApplicationType == WebApplicationType.SERVLET) {
200-
((AnnotationConfigServletWebServerApplicationContext)applicationContext).setServletContext(getServletContext());
203+
((ConfigurableWebApplicationContext)applicationContext).setServletContext(getServletContext());
201204
AwsServletRegistration reg = (AwsServletRegistration)getServletContext().getServletRegistration(DISPATCHER_SERVLET_REGISTRATION_NAME);
202205
if (reg != null) {
203206
reg.setLoadOnStartup(1);

0 commit comments

Comments
 (0)