springboot项目
示例:test.zip
根据fun init custom-springboot改编
0、添加引用
方便使用日志系统,如果不用日志,也可以不加
<dependency><groupId>com.aliyun.fc.runtime</groupId><artifactId>fc-java-core</artifactId><version>1.3.0</version></dependency>
打印日志示例:

1、项目根目录新建fun配置。
template.yml
ROSTemplateFormatVersion: '2015-09-01'Transform: 'Aliyun::Serverless-2018-04-03'Resources:springboot: # service nameType: 'Aliyun::Serverless::Service'Properties:Description: This is a FC service for springboothelloworld: # function nameType: 'Aliyun::Serverless::Function'Properties:Handler: com.example.demo.DemoApplication::mainRuntime: customCodeUri: ./MemorySize: 1024Timeout: 15Events:httpTrigger:Type: HTTPProperties:AuthType: ANONYMOUSMethods: ['GET', 'POST', 'PUT']
2、bootstrap
#!/usr/bin/env bashjava -jar target/demo.jar
3、application.propertites添加
server.servlet.context-path=/helloworld/
4、上传即可
mvn clean package# 先上传到OSS,注意oss区域要和函数计算的区域保持一致,比如:都在上海区域。fun package -b tianyunperfect# 再发布,这样不会有超时情况fun deploy
5、在线操作:修改、上传、下载

