Imporovement of serverless web integration
This commit is contained in:
@@ -32,48 +32,17 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.github.crac</groupId>
|
||||
<artifactId>org-crac</artifactId>
|
||||
<version>0.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-function-adapter-aws-web</artifactId>
|
||||
<version>3.2.9-SNAPSHOT</version>
|
||||
<version>4.0.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!--
|
||||
the Spring Context Indexer run an annotation processor at compile time and generates
|
||||
a META-INF/spring.components file that Spring can use to speed up component scanning at boot time.
|
||||
For small applications, this doesn't make a big difference. However, for large applications with
|
||||
complex dependencies this may improve your cold start time significantly.
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-indexer</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-lambda-java-log4j2</artifactId>
|
||||
<version>1.5.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package oz.spring.petstore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
@@ -29,25 +26,13 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
@Configuration
|
||||
@Import({ PetsController.class })
|
||||
public class PetStoreSpringAppConfig {
|
||||
/*
|
||||
* Create required HandlerMapping, to avoid several default HandlerMapping instances being created
|
||||
*/
|
||||
@Bean
|
||||
public HandlerMapping handlerMapping() {
|
||||
return new RequestMappingHandlerMapping();
|
||||
}
|
||||
|
||||
/*
|
||||
* Create required HandlerAdapter, to avoid several default HandlerAdapter instances being created
|
||||
*/
|
||||
@Bean
|
||||
public HandlerAdapter handlerAdapter() {
|
||||
return new RequestMappingHandlerAdapter();
|
||||
}
|
||||
|
||||
/*
|
||||
* optimization - avoids creating default exception resolvers; not required as the serverless container handles
|
||||
|
||||
@@ -11,10 +11,14 @@ Resources:
|
||||
PetStoreFunction:
|
||||
Type: AWS::Serverless::Function
|
||||
Properties:
|
||||
# AutoPublishAlias: bcn
|
||||
FunctionName: pet-store-17
|
||||
Handler: org.springframework.cloud.function.adapter.aws.web.WebProxyInvoker::handleRequest
|
||||
Runtime: java17
|
||||
SnapStart:
|
||||
ApplyOn: PublishedVersions
|
||||
CodeUri: .
|
||||
MemorySize: 512
|
||||
MemorySize: 1024
|
||||
Policies: AWSLambdaBasicExecutionRole
|
||||
Timeout: 30
|
||||
Environment:
|
||||
@@ -32,6 +36,6 @@ Outputs:
|
||||
Description: URL for application
|
||||
Value: !Sub 'https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/pets'
|
||||
Export:
|
||||
Name: PetStoreLambda
|
||||
Name: SpringPetStoreApi
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user