Skip to content

Commit 180b4d4

Browse files
authored
Merge pull request #74 from devsapp/add-java11
add java11 example
2 parents 26a87f4 + 4414ff6 commit 180b4d4

File tree

22 files changed

+1167
-41
lines changed

22 files changed

+1167
-41
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# 快速体验 Java11 Event 函数案例
2+
3+
欢迎您使用 Serverless Devs 开发者工具进行项目开发,本实验是基于 Serverless Devs 部署 Java11 Event 案例到阿里云函数计算。
4+
5+
整个实验过程包括:
6+
7+
- [下载工具](#下载工具)
8+
- [配置密钥](#配置密钥)
9+
- [初始化项目](#初始化项目)
10+
- [部署项目](#部署项目)
11+
- [更多信息](#更多信息)
12+
13+
> - [:octocat: 源代码](https://github.com/devsapp/start-fc/tree/main/event-function/fc-event-java11/src)
14+
15+
## 下载工具
16+
17+
> 由于本系统已经默认集成了 Serverless Devs,所以该步骤在本次试验中可以跳过
18+
19+
通过`npm`安装 Serverless Devs 开发者工具:
20+
21+
```
22+
npm install -g @serverless-devs/s
23+
```
24+
25+
除了上述的安装方法之外,您还可以参考[Serverless Devs Cli 安装文档](https://www.serverless-devs.com/serverless-devs/install) 查看更多安装方法。
26+
27+
## 配置密钥
28+
29+
> 由于本系统已经配置了密钥信息,所以该步骤在本次试验中可以跳过
30+
31+
配置阿里云账号的 AccessKeyID, AccessKeySecret 以及密钥别名。
32+
33+
配置方法可以通过`s config add`指令,选择`Alibaba Cloud`并根据提示进行配置。
34+
35+
除了上述的配置方法之外,您还可以参考[Serverless Devs 配置阿里云密钥信息](https://www.serverless-devs.com/fc/config) 查看更多密钥配置方法。
36+
37+
## 初始化项目
38+
39+
进行项目初始化:
40+
41+
```
42+
s init start-fc-event-java11 -d start-fc-event-java11
43+
```
44+
45+
在初始化的过程中,可能涉及到部分服务的开通、参数的获取以及参数的定义,请根据命令行的提醒进行具体的操作。
46+
47+
## 部署项目
48+
49+
- 进入项目:`cd start-fc-event-java11`
50+
- 进行项目的部署:`s deploy`
51+
52+
稍等片刻,即可完成项目的部署。
53+
54+
## 更多信息
55+
56+
- 组件仓库地址:https://github.com/devsapp/fc
57+
- 组件帮助文档:https://www.serverless-devs.com/fc/readme
58+
- Yaml 参考文档:https://www.serverless-devs.com/fc/yaml/readme
59+
- 关于:
60+
- Serverless Devs 和 FC 组件的关系、如何声明/部署多个函数、超过 50M 的代码包如何部署
61+
- 关于.fcignore 使用方法、工具中.s 目录是做什么、函数进行 build 操作之后如何处理 build 的产物
62+
等问题,可以参考文档:https://www.serverless-devs.com/fc/tips
63+
- 关于如何做 CICD 等问题,可以参考:https://www.serverless-devs.com/serverless-devs/cicd
64+
- 关于如何进行环境划分等问题,可以参考:https://www.serverless-devs.com/serverless-devs/extend
65+
66+
更多函数计算案例,可参考:https://github.com/devsapp/awesome/
67+
68+
> 有问题快来钉钉群问一下吧:33947367
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
async function preInit(inputObj) {
2+
console.log(`
3+
Serverless Devs Application Case
4+
5+
Cloud services required:
6+
- FC : https://fc.console.aliyun.com/
7+
8+
Tips:
9+
- FC Component: https://www.serverless-devs.com/fc/readme`)
10+
11+
}
12+
13+
async function postInit(inputObj) {
14+
console.log(`
15+
* Before using, please check whether the actions command in Yaml file is available
16+
* Carefully reading the notes in s.yaml is helpful for the use of the tool
17+
* If need help in the use process, please apply to join the Dingtalk Group: 33947367
18+
`)
19+
}
20+
21+
module.exports = {
22+
postInit,
23+
preInit
24+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Type: Application
2+
Name: start-fc-event-java11
3+
Version: 0.0.1
4+
Provider:
5+
- 阿里云
6+
Description: 快速部署一个 Java 11 的 Event 类型的 Hello World 函数到阿里云函数计算。
7+
HomePage: https://github.com/devsapp/start-fc
8+
Tags:
9+
- 函数计算
10+
- 你好世界
11+
- 新手入门
12+
Category: 新手入门
13+
Service:
14+
函数计算:
15+
Authorities:
16+
- AliyunFCFullAccess
17+
Runtime: Java11
18+
Parameters:
19+
type: object
20+
additionalProperties: false # 不允许增加其他属性
21+
required: # 必填项
22+
- region
23+
- serviceName
24+
- functionName
25+
properties:
26+
region:
27+
title: 地域
28+
type: string
29+
default: cn-hangzhou
30+
description: 创建应用所在的地区
31+
enum:
32+
- cn-beijing
33+
- cn-hangzhou
34+
- cn-shanghai
35+
- cn-qingdao
36+
- cn-zhangjiakou
37+
- cn-huhehaote
38+
- cn-shenzhen
39+
- cn-chengdu
40+
- cn-hongkong
41+
- ap-southeast-1
42+
- ap-southeast-2
43+
- ap-southeast-3
44+
- ap-southeast-5
45+
- ap-northeast-1
46+
- eu-central-1
47+
- eu-west-1
48+
- us-west-1
49+
- us-east-1
50+
- ap-south-1
51+
serviceName:
52+
title: 服务名
53+
type: string
54+
default: hello-world-service
55+
description: 服务名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间
56+
functionName:
57+
title: 函数名
58+
type: string
59+
default: start-fc-event-java11
60+
description: 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-64 之间
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# start-fc-event-java11 帮助文档
2+
3+
<p align="center" class="flex justify-center">
4+
<a href="https://www.serverless-devs.com" class="ml-1">
5+
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageType">
6+
</a>
7+
<a href="http://www.devsapp.cn/details.html?name=start-fc-event-java11" class="ml-1">
8+
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageVersion">
9+
</a>
10+
<a href="http://www.devsapp.cn/details.html?name=start-fc-event-java11" class="ml-1">
11+
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageDownload">
12+
</a>
13+
</p>
14+
15+
<description>
16+
17+
快速部署一个 Java 11 的 Event 类型的 Hello World 函数到阿里云函数计算。
18+
19+
</description>
20+
21+
<table>
22+
23+
## 前期准备
24+
25+
使用该项目,推荐您拥有以下的产品权限 / 策略:
26+
27+
| 服务/业务 | 函数计算 |
28+
| --------- | ------------------ |
29+
| 权限/策略 | AliyunFCFullAccess |
30+
31+
</table>
32+
33+
<codepre id="codepre">
34+
35+
# 代码 & 预览
36+
37+
- [ :smiley_cat: 源代码](https://github.com/devsapp/start-fc/blob/main/event-function/fc-event-java11)
38+
39+
</codepre>
40+
41+
<deploy>
42+
43+
## 部署 & 体验
44+
45+
<appcenter>
46+
47+
- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc-event-java11)
48+
[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc-event-java11) 该应用。
49+
50+
</appcenter>
51+
52+
- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
53+
- [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://www.serverless-devs.com/fc/config)
54+
- 初始化项目:`s init start-fc-event-java11 -d start-fc-event-java11`
55+
- 进入项目,并进行项目部署:`cd start-fc-event-java11 && s deploy -y`
56+
57+
</deploy>
58+
59+
<appdetail id="flushContent">
60+
61+
# 应用详情
62+
63+
本应用仅作为学习和参考使用,您可以基于本项目进行二次开发和完善,实现自己的业务逻辑
64+
65+
</appdetail>
66+
67+
<devgroup>
68+
69+
## 开发者社区
70+
71+
您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:
72+
73+
<p align="center">
74+
75+
| <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407252200_20211028074732517533.png" width="130px" > |
76+
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
77+
| <center>微信公众号:`serverless`</center> | <center>微信小助手:`xiaojiangwh`</center> | <center>钉钉交流群:`33947367`</center> |
78+
79+
</p>
80+
81+
</devgroup>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>example</groupId>
5+
<artifactId>HelloFCJava</artifactId>
6+
<packaging>jar</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>HelloFCJava</name>
9+
10+
<dependencies>
11+
<dependency>
12+
<groupId>junit</groupId>
13+
<artifactId>junit</artifactId>
14+
<version>3.8.1</version>
15+
<scope>test</scope>
16+
</dependency>
17+
<dependency>
18+
<groupId>com.aliyun.fc.runtime</groupId>
19+
<artifactId>fc-java-core</artifactId>
20+
<version>1.3.0</version>
21+
</dependency>
22+
</dependencies>
23+
24+
<build>
25+
<plugins>
26+
<plugin>
27+
<artifactId>maven-assembly-plugin</artifactId>
28+
<configuration>
29+
<descriptorRefs>
30+
<descriptorRef>jar-with-dependencies</descriptorRef>
31+
</descriptorRefs>
32+
</configuration>
33+
<executions>
34+
<execution>
35+
<id>make-my-jar-with-dependencies</id>
36+
<phase>package</phase>
37+
<goals>
38+
<goal>single</goal>
39+
</goals>
40+
</execution>
41+
</executions>
42+
</plugin>
43+
</plugins>
44+
</build>
45+
46+
<properties>
47+
<maven.compiler.release>11</maven.compiler.release>
48+
<maven.test.skip>true</maven.test.skip>
49+
</properties>
50+
</project>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# start-fc-event-java11 帮助文档
2+
3+
<p align="center" class="flex justify-center">
4+
<a href="https://www.serverless-devs.com" class="ml-1">
5+
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageType">
6+
</a>
7+
<a href="http://www.devsapp.cn/details.html?name=start-fc-event-java11" class="ml-1">
8+
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageVersion">
9+
</a>
10+
<a href="http://www.devsapp.cn/details.html?name=start-fc-event-java11" class="ml-1">
11+
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageDownload">
12+
</a>
13+
</p>
14+
15+
<description>
16+
17+
快速部署一个 Java 11 的 Event 类型的 Hello World 函数到阿里云函数计算。
18+
19+
</description>
20+
21+
<table>
22+
23+
## 前期准备
24+
25+
使用该项目,推荐您拥有以下的产品权限 / 策略:
26+
27+
| 服务/业务 | 函数计算 |
28+
| --------- | ------------------ |
29+
| 权限/策略 | AliyunFCFullAccess |
30+
31+
</table>
32+
33+
<codepre id="codepre">
34+
35+
# 代码 & 预览
36+
37+
- [ :smiley_cat: 源代码](https://github.com/devsapp/start-fc/blob/main/event-function/fc-event-java11)
38+
39+
</codepre>
40+
41+
<deploy>
42+
43+
## 部署 & 体验
44+
45+
<appcenter>
46+
47+
- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc-event-java11)
48+
[![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc-event-java11) 该应用。
49+
50+
</appcenter>
51+
52+
- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
53+
- [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://www.serverless-devs.com/fc/config)
54+
- 初始化项目:`s init start-fc-event-java11 -d start-fc-event-java11`
55+
- 进入项目,并进行项目部署:`cd start-fc-event-java11 && s deploy -y`
56+
57+
</deploy>
58+
59+
<appdetail id="flushContent">
60+
61+
# 应用详情
62+
63+
本应用仅作为学习和参考使用,您可以基于本项目进行二次开发和完善,实现自己的业务逻辑
64+
65+
</appdetail>
66+
67+
<devgroup>
68+
69+
## 开发者社区
70+
71+
您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:
72+
73+
<p align="center">
74+
75+
| <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="130px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407252200_20211028074732517533.png" width="130px" > |
76+
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
77+
| <center>微信公众号:`serverless`</center> | <center>微信小助手:`xiaojiangwh`</center> | <center>钉钉交流群:`33947367`</center> |
78+
79+
</p>
80+
81+
</devgroup>

0 commit comments

Comments
 (0)