Skip to content

Commit

Permalink
Merge pull request #74 from devsapp/add-java11
Browse files Browse the repository at this point in the history
add java11 example
  • Loading branch information
rsonghuster authored Apr 3, 2023
2 parents 26a87f4 + 4414ff6 commit 180b4d4
Show file tree
Hide file tree
Showing 22 changed files with 1,167 additions and 41 deletions.
68 changes: 68 additions & 0 deletions event-function/fc-event-java11/cloudshell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 快速体验 Java11 Event 函数案例

欢迎您使用 Serverless Devs 开发者工具进行项目开发,本实验是基于 Serverless Devs 部署 Java11 Event 案例到阿里云函数计算。

整个实验过程包括:

- [下载工具](#下载工具)
- [配置密钥](#配置密钥)
- [初始化项目](#初始化项目)
- [部署项目](#部署项目)
- [更多信息](#更多信息)

> - [:octocat: 源代码](https://github.com/devsapp/start-fc/tree/main/event-function/fc-event-java11/src)
## 下载工具

> 由于本系统已经默认集成了 Serverless Devs,所以该步骤在本次试验中可以跳过
通过`npm`安装 Serverless Devs 开发者工具:

```
npm install -g @serverless-devs/s
```

除了上述的安装方法之外,您还可以参考[Serverless Devs Cli 安装文档](https://www.serverless-devs.com/serverless-devs/install) 查看更多安装方法。

## 配置密钥

> 由于本系统已经配置了密钥信息,所以该步骤在本次试验中可以跳过
配置阿里云账号的 AccessKeyID, AccessKeySecret 以及密钥别名。

配置方法可以通过`s config add`指令,选择`Alibaba Cloud`并根据提示进行配置。

除了上述的配置方法之外,您还可以参考[Serverless Devs 配置阿里云密钥信息](https://www.serverless-devs.com/fc/config) 查看更多密钥配置方法。

## 初始化项目

进行项目初始化:

```
s init start-fc-event-java11 -d start-fc-event-java11
```

在初始化的过程中,可能涉及到部分服务的开通、参数的获取以及参数的定义,请根据命令行的提醒进行具体的操作。

## 部署项目

- 进入项目:`cd start-fc-event-java11`
- 进行项目的部署:`s deploy`

稍等片刻,即可完成项目的部署。

## 更多信息

- 组件仓库地址:https://github.com/devsapp/fc
- 组件帮助文档:https://www.serverless-devs.com/fc/readme
- Yaml 参考文档:https://www.serverless-devs.com/fc/yaml/readme
- 关于:
- Serverless Devs 和 FC 组件的关系、如何声明/部署多个函数、超过 50M 的代码包如何部署
- 关于.fcignore 使用方法、工具中.s 目录是做什么、函数进行 build 操作之后如何处理 build 的产物
等问题,可以参考文档:https://www.serverless-devs.com/fc/tips
- 关于如何做 CICD 等问题,可以参考:https://www.serverless-devs.com/serverless-devs/cicd
- 关于如何进行环境划分等问题,可以参考:https://www.serverless-devs.com/serverless-devs/extend

更多函数计算案例,可参考:https://github.com/devsapp/awesome/

> 有问题快来钉钉群问一下吧:33947367
24 changes: 24 additions & 0 deletions event-function/fc-event-java11/hook/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
async function preInit(inputObj) {
console.log(`
Serverless Devs Application Case
Cloud services required:
- FC : https://fc.console.aliyun.com/
Tips:
- FC Component: https://www.serverless-devs.com/fc/readme`)

}

async function postInit(inputObj) {
console.log(`
* Before using, please check whether the actions command in Yaml file is available
* Carefully reading the notes in s.yaml is helpful for the use of the tool
* If need help in the use process, please apply to join the Dingtalk Group: 33947367
`)
}

module.exports = {
postInit,
preInit
}
60 changes: 60 additions & 0 deletions event-function/fc-event-java11/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Type: Application
Name: start-fc-event-java11
Version: 0.0.1
Provider:
- 阿里云
Description: 快速部署一个 Java 11 的 Event 类型的 Hello World 函数到阿里云函数计算。
HomePage: https://github.com/devsapp/start-fc
Tags:
- 函数计算
- 你好世界
- 新手入门
Category: 新手入门
Service:
函数计算:
Authorities:
- AliyunFCFullAccess
Runtime: Java11
Parameters:
type: object
additionalProperties: false # 不允许增加其他属性
required: # 必填项
- region
- serviceName
- functionName
properties:
region:
title: 地域
type: string
default: cn-hangzhou
description: 创建应用所在的地区
enum:
- cn-beijing
- cn-hangzhou
- cn-shanghai
- cn-qingdao
- cn-zhangjiakou
- cn-huhehaote
- cn-shenzhen
- cn-chengdu
- cn-hongkong
- ap-southeast-1
- ap-southeast-2
- ap-southeast-3
- ap-southeast-5
- ap-northeast-1
- eu-central-1
- eu-west-1
- us-west-1
- us-east-1
- ap-south-1
serviceName:
title: 服务名
type: string
default: hello-world-service
description: 服务名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间
functionName:
title: 函数名
type: string
default: start-fc-event-java11
description: 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-64 之间
81 changes: 81 additions & 0 deletions event-function/fc-event-java11/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# start-fc-event-java11 帮助文档

<p align="center" class="flex justify-center">
<a href="https://www.serverless-devs.com" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageType">
</a>
<a href="http://www.devsapp.cn/details.html?name=start-fc-event-java11" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageVersion">
</a>
<a href="http://www.devsapp.cn/details.html?name=start-fc-event-java11" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageDownload">
</a>
</p>

<description>

快速部署一个 Java 11 的 Event 类型的 Hello World 函数到阿里云函数计算。

</description>

<table>

## 前期准备

使用该项目,推荐您拥有以下的产品权限 / 策略:

| 服务/业务 | 函数计算 |
| --------- | ------------------ |
| 权限/策略 | AliyunFCFullAccess |

</table>

<codepre id="codepre">

# 代码 & 预览

- [ :smiley_cat: 源代码](https://github.com/devsapp/start-fc/blob/main/event-function/fc-event-java11)

</codepre>

<deploy>

## 部署 & 体验

<appcenter>

- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc-event-java11)
[![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) 该应用。

</appcenter>

- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
- [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://www.serverless-devs.com/fc/config)
- 初始化项目:`s init start-fc-event-java11 -d start-fc-event-java11`
- 进入项目,并进行项目部署:`cd start-fc-event-java11 && s deploy -y`

</deploy>

<appdetail id="flushContent">

# 应用详情

本应用仅作为学习和参考使用,您可以基于本项目进行二次开发和完善,实现自己的业务逻辑

</appdetail>

<devgroup>

## 开发者社区

您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:

<p align="center">

| <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" > |
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| <center>微信公众号:`serverless`</center> | <center>微信小助手:`xiaojiangwh`</center> | <center>钉钉交流群:`33947367`</center> |

</p>

</devgroup>
50 changes: 50 additions & 0 deletions event-function/fc-event-java11/src/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
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">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>HelloFCJava</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>HelloFCJava</name>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aliyun.fc.runtime</groupId>
<artifactId>fc-java-core</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<maven.test.skip>true</maven.test.skip>
</properties>
</project>
81 changes: 81 additions & 0 deletions event-function/fc-event-java11/src/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# start-fc-event-java11 帮助文档

<p align="center" class="flex justify-center">
<a href="https://www.serverless-devs.com" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageType">
</a>
<a href="http://www.devsapp.cn/details.html?name=start-fc-event-java11" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageVersion">
</a>
<a href="http://www.devsapp.cn/details.html?name=start-fc-event-java11" class="ml-1">
<img src="http://editor.devsapp.cn/icon?package=start-fc-event-java11&type=packageDownload">
</a>
</p>

<description>

快速部署一个 Java 11 的 Event 类型的 Hello World 函数到阿里云函数计算。

</description>

<table>

## 前期准备

使用该项目,推荐您拥有以下的产品权限 / 策略:

| 服务/业务 | 函数计算 |
| --------- | ------------------ |
| 权限/策略 | AliyunFCFullAccess |

</table>

<codepre id="codepre">

# 代码 & 预览

- [ :smiley_cat: 源代码](https://github.com/devsapp/start-fc/blob/main/event-function/fc-event-java11)

</codepre>

<deploy>

## 部署 & 体验

<appcenter>

- :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc-event-java11)
[![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) 该应用。

</appcenter>

- 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署:
- [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://www.serverless-devs.com/fc/config)
- 初始化项目:`s init start-fc-event-java11 -d start-fc-event-java11`
- 进入项目,并进行项目部署:`cd start-fc-event-java11 && s deploy -y`

</deploy>

<appdetail id="flushContent">

# 应用详情

本应用仅作为学习和参考使用,您可以基于本项目进行二次开发和完善,实现自己的业务逻辑

</appdetail>

<devgroup>

## 开发者社区

您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行:

<p align="center">

| <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" > |
| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| <center>微信公众号:`serverless`</center> | <center>微信小助手:`xiaojiangwh`</center> | <center>钉钉交流群:`33947367`</center> |

</p>

</devgroup>
Loading

0 comments on commit 180b4d4

Please sign in to comment.