Skip to content

Commit 168b6e0

Browse files
committedOct 3, 2021
showcase successful Spring Cloud Function example for Kotlin and AWS
1 parent 8bededc commit 168b6e0

File tree

5 files changed

+55
-25
lines changed

5 files changed

+55
-25
lines changed
 

‎spring-cloud-function-aws-kotlin/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ target/
1313
.springBeans
1414
.sts4-cache
1515

16+
.gradle
17+
.serverless
18+
1619
### IntelliJ IDEA ###
1720
.idea
1821
*.iws

‎spring-cloud-function-aws-kotlin/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Minimum Reproducible Example for a Spring Boot + Kotlin + Spring Cloud AWS Lambda Setup
22

3+
**Fixed since Spring Cloud Function > 3.2.0-M2**: https://github.com/spring-cloud/spring-cloud-function/issues/747
4+
35
Steps to reproduce:
46

57
1. `npm install -g serverless`

‎spring-cloud-function-aws-kotlin/pom.xml

+36-23
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<properties>
2020
<java.version>11</java.version>
2121
<kotlin.version>1.5.31</kotlin.version>
22-
<spring-cloud.version>2020.0.4</spring-cloud.version>
22+
<spring-cloud-function.version>3.2.0-M2</spring-cloud-function.version>
2323
<wrapper.version>1.0.27.RELEASE</wrapper.version>
2424
</properties>
2525

@@ -52,12 +52,13 @@
5252
<scope>test</scope>
5353
</dependency>
5454
</dependencies>
55+
5556
<dependencyManagement>
5657
<dependencies>
5758
<dependency>
5859
<groupId>org.springframework.cloud</groupId>
59-
<artifactId>spring-cloud-dependencies</artifactId>
60-
<version>${spring-cloud.version}</version>
60+
<artifactId>spring-cloud-function-dependencies</artifactId>
61+
<version>${spring-cloud-function.version}</version>
6162
<type>pom</type>
6263
<scope>import</scope>
6364
</dependency>
@@ -103,33 +104,14 @@
103104
<groupId>org.apache.maven.plugins</groupId>
104105
<artifactId>maven-shade-plugin</artifactId>
105106
<version>3.2.4</version>
106-
<dependencies>
107-
<dependency>
108-
<groupId>org.springframework.boot</groupId>
109-
<artifactId>spring-boot-maven-plugin</artifactId>
110-
<version>2.5.5</version>
111-
</dependency>
112-
</dependencies>
113107
<configuration>
114108
<createDependencyReducedPom>false</createDependencyReducedPom>
115109
<shadedArtifactAttached>true</shadedArtifactAttached>
116110
<shadedClassifierName>aws</shadedClassifierName>
117-
<transformers>
118-
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
119-
<resource>META-INF/spring.handlers</resource>
120-
</transformer>
121-
<transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
122-
<resource>META-INF/spring.factories</resource>
123-
</transformer>
124-
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
125-
<resource>META-INF/spring.schemas</resource>
126-
</transformer>
127-
</transformers>
128111
</configuration>
129112
</plugin>
130113
</plugins>
131114
</build>
132-
133115
<repositories>
134116
<repository>
135117
<snapshots>
@@ -147,6 +129,22 @@
147129
<enabled>false</enabled>
148130
</snapshots>
149131
</repository>
132+
<repository>
133+
<id>spring-snapshots</id>
134+
<name>Spring Snapshots</name>
135+
<url>https://repo.spring.io/snapshot</url>
136+
<snapshots>
137+
<enabled>true</enabled>
138+
</snapshots>
139+
</repository>
140+
<repository>
141+
<id>spring-milestones</id>
142+
<name>Spring Milestones</name>
143+
<url>https://repo.spring.io/milestone</url>
144+
<snapshots>
145+
<enabled>false</enabled>
146+
</snapshots>
147+
</repository>
150148
</repositories>
151149
<pluginRepositories>
152150
<pluginRepository>
@@ -165,7 +163,22 @@
165163
<enabled>false</enabled>
166164
</snapshots>
167165
</pluginRepository>
166+
<pluginRepository>
167+
<id>spring-snapshots</id>
168+
<name>Spring Snapshots</name>
169+
<url>https://repo.spring.io/snapshot</url>
170+
<snapshots>
171+
<enabled>true</enabled>
172+
</snapshots>
173+
</pluginRepository>
174+
<pluginRepository>
175+
<id>spring-milestones</id>
176+
<name>Spring Milestones</name>
177+
<url>https://repo.spring.io/milestone</url>
178+
<snapshots>
179+
<enabled>false</enabled>
180+
</snapshots>
181+
</pluginRepository>
168182
</pluginRepositories>
169183

170-
171184
</project>

‎spring-cloud-function-aws-kotlin/serverless.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
service: marketing-automation
1+
service: kotlin-spring-cloud-aws-test
22

33
variablesResolutionMode: 20210326
44

@@ -19,4 +19,4 @@ functions:
1919
test:
2020
handler: org.springframework.cloud.function.adapter.aws.FunctionInvoker
2121
environment:
22-
MAIN_CLASS: org.springframework.boot.loader.wrapper.ThinJarWrapper
22+
SPRING_CLOUD_FUNCTION_DEFINITION: test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
4+
5+
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
6+
7+
<logger name="org.springframework.cloud.function.utils.FunctionClassUtils" level="WARN"/>
8+
9+
<root level="INFO">
10+
<appender-ref ref="CONSOLE"/>
11+
</root>
12+
</configuration>

0 commit comments

Comments
 (0)
Please sign in to comment.