ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
jfinal-demo: # service name
Type: 'Aliyun::Serverless::Service'
Properties:
Description: This is FC service
jfinal-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: jfinal-demo
FunctionName: jfinal-demo
在本地启动项目
mvn clean package
java -jar jfinal-demo.jar
启动日志如下
Starting JFinal 4.9.13 -> http://0.0.0.0:80
Info: jfinal-undertow 2.5, undertow 2.0.34.Final, jvm 1.8.0_121
六月 27, 2021 7:27:32 下午 io.undertow.Undertow start
INFO: starting server: Undertow - 2.0.34.Final
六月 27, 2021 7:27:32 下午 org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
六月 27, 2021 7:27:32 下午 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
Starting Complete in 0.7 seconds. Welcome To The JFinal World (^_^)
我为添加了2个http接口,访问一下,都访问成功
发布项目到阿里云,提示发布成功
E:\dev_workspace\java\java-study\java-aliyun-fc-study\jfinal-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 │
├─────────────┼──────────────────────────────┼────────┼─────────────────────┤
│ jfinal-demo │ Aliyun::Serverless::Service │ Add │ Description │
├─────────────┼──────────────────────────────┼────────┼─────────────────────┤
│ │ │ │ Handler │
│ │ │ ├─────────────────────┤
│ │ │ │ Runtime │
│ │ │ ├─────────────────────┤
│ │ │ │ CodeUri │
│ jfinal-demo │ Aliyun::Serverless::Function │ Add ├─────────────────────┤
│ │ │ │ MemorySize │
│ │ │ ├─────────────────────┤
│ │ │ │ InstanceConcurrency │
│ │ │ ├─────────────────────┤
│ │ │ │ Timeout │
├─────────────┼──────────────────────────────┼────────┼─────────────────────┤
│ │ │ │ AuthType │
│ httpTrigger │ HTTP │ Add ├─────────────────────┤
│ │ │ │ Methods │
└─────────────┴──────────────────────────────┴────────┴─────────────────────┘
Waiting for service jfinal-demo to be deployed...
Waiting for function jfinal-demo to be deployed...
Waiting for packaging function jfinal-demo code...
The function jfinal-demo has been packaged. A total of 22 files were compressed and the final size was 3.86 MB
Waiting for HTTP trigger httpTrigger to be deployed...
triggerName: httpTrigger
methods: [ 'GET', 'POST', 'PUT' ]
trigger httpTrigger deploy success
function jfinal-demo deploy success
service jfinal-demo deploy success
Detect 'DomainName:Auto' of custom domain 'Domain'
Request a new temporary domain ...
The assigned temporary domain is http://54793386-1709155087484149.test.functioncompute.com,expired at 2021-07-07 19:29:46, limited by 1000 per day.
Waiting for custom domain Domain to be deployed...
custom domain Domain deploy success
funcraft的版本是3.6.23 jfinal是一款国产的java web框架
我创建了一个jfinal项目,代码地址
template.yml内容如下
在本地启动项目
启动日志如下
我为添加了2个http接口,访问一下,都访问成功 发布项目到阿里云,提示发布成功
使用自定义域名 http://54793386-1709155087484149.test.functioncompute.com 访问时出现下面的错误 后来我添加了bootstrap文件,文件内容如下
重新发布并访问,出现测错误如下