ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
spring-boot-demo: # service name
Type: 'Aliyun::Serverless::Service'
Properties:
Description: This is FC service
spring-boot-demo: # function name
Type: 'Aliyun::Serverless::Function'
Properties:
Handler: index.handler
Runtime: custom
CodeUri: ./
MemorySize: 1024
InstanceConcurrency: 5
Timeout: 120
Events:
httpTrigger:
Type: HTTP
Properties:
AuthType: ANONYMOUS
Methods: ['GET', 'POST', 'PUT']
Domain:
Type: Aliyun::Serverless::CustomDomain
Properties:
DomainName: Auto
Protocol: HTTP
RouteConfig:
Routes:
"/*":
ServiceName: spring-boot-demo
FunctionName: spring-boot-demo
该工程一种与2个http接口,我fun deploy -y 部署到阿里云,部署成功,显示日志如下
E:\dev_workspace\java\java-study\java-aliyun-fc-study\spring-boot-demo>fun deploy -y
using template: .fun\build\artifacts\template.yml
ENOENT: no such file or directory, lstat 'E:\dev_workspace\eclipse-jee-2019-12\spring-boot-demo'
E:\dev_workspace\java\java-study\java-aliyun-fc-study\spring-boot-demo>fun deploy -y
using template: template.yml
using region: cn-shanghai
using accountId: ***********4149
using accessKeyId: ***********9Wqn
using timeout: 10
Collecting your services information, in order to caculate devlopment changes...
Resources Changes(Beta version! Only FC resources changes will be displayed):
┌──────────────────┬──────────────────────────────┬────────┬─────────────────────┐
│ Resource │ ResourceType │ Action │ Property │
├──────────────────┼──────────────────────────────┼────────┼─────────────────────┤
│ │ │ │ Handler │
│ │ │ ├─────────────────────┤
│ │ │ │ Runtime │
│ │ │ ├─────────────────────┤
│ │ │ │ CodeUri │
│ spring-boot-demo │ Aliyun::Serverless::Function │ Add ├─────────────────────┤
│ │ │ │ MemorySize │
│ │ │ ├─────────────────────┤
│ │ │ │ InstanceConcurrency │
│ │ │ ├─────────────────────┤
│ │ │ │ Timeout │
├──────────────────┼──────────────────────────────┼────────┼─────────────────────┤
│ │ │ │ AuthType │
│ httpTrigger │ HTTP │ Add ├─────────────────────┤
│ │ │ │ Methods │
└──────────────────┴──────────────────────────────┴────────┴─────────────────────┘
Waiting for service spring-boot-demo to be deployed...
Waiting for function spring-boot-demo to be deployed...
Waiting for packaging function spring-boot-demo code...
The function spring-boot-demo has been packaged. A total of 5 files were compressed and the final size was 14.05 MB
Waiting for HTTP trigger httpTrigger to be deployed...
triggerName: httpTrigger
methods: [ 'GET', 'POST', 'PUT' ]
trigger httpTrigger deploy success
function spring-boot-demo deploy success
service spring-boot-demo deploy success
Detect 'DomainName:Auto' of custom domain 'Domain'
Request a new temporary domain ...
The assigned temporary domain is http://54790713-1709155087484149.test.functioncompute.com,expired at 2021-07-07 18:45:13, limited by 1000 per day.
Waiting for custom domain Domain to be deployed...
custom domain Domain deploy success
E:\dev_workspace\java\java-study\java-aliyun-fc-study\spring-boot-demo>fun build
using template: template.yml
start building function dependencies without docker
building spring-boot-demo/spring-boot-demo
running task: flow MavenTaskFlow
running task: MavenCompileTask
running task: MavenCopyDependencies
running task: CopyMavenArtifacts
Build Success
Built artifacts: .fun\build\artifacts
Built template: .fun\build\artifacts\template.yml
Tips for next step
======================
* Invoke Event Function: fun local invoke
* Invoke Http Function: fun local start
* Deploy Resources: fun deploy
然后我在本地启动,显示启动成功
E:\dev_workspace\java\java-study\java-aliyun-fc-study\spring-boot-demo>fun local start
using template: .fun\build\artifacts\template.yml
HttpTrigger httpTrigger of spring-boot-demo/spring-boot-demo was registered
url: http://localhost:8000/2016-08-15/proxy/spring-boot-demo/spring-boot-demo/
methods: [ 'GET', 'POST', 'PUT' ]
authType: ANONYMOUS
Tips:you can also use these commands to run/debug custom domain resources:
Start with customDomain:
* fun local start Domain
Debug with customDomain:
* fun local start -d 3000 Domain
function compute app listening on port 8000!
skip pulling image aliyunfc/runtime-custom:1.9.17...
sh: 1: /code/bootstrap: not found
2021/06/27 11:00:00 exit status 127
Fun Error:
/var/fc/runtime/custom/mock exited with code 126
环境概述 平台 windows 10 funcraft:3.6.23 [问题描述] 我写了一个spring-boot工程,代码如下 https://gitee.com/litongjava_admin/java-aliyun-fc-study/tree/master/spring-boot-demo 对应的template.yml如下
该工程一种与2个http接口,我fun deploy -y 部署到阿里云,部署成功,显示日志如下
从上面的信息可以看到,分配的临时域名是http://54790713-1709155087484149.test.functioncompute.com 然后我测试访问2个接口都成功了
接下来我要做的是从本地调试 我先是构建,显示构建成功
然后我在本地启动,显示启动成功
但是本地成功后我该如何访问我spring-boot中的接口呢? 访问http://localhost:8000/2016-08-15/proxy/spring-boot-demo/spring-boot-demo/浏览器显示如下 同时日志显示如下
我应该使用什么正确的方式访问我上面开发的2个接口呢?