使用AWS-AppSync实时监控物联网设备iOS端

news2025/1/8 19:45:26

aws-appsync-iot-core-实时iOS端示例

第一步参考如下资料

  1. 第一步找资料

网址: https://aws.amazon.com/cn/blogs/mobile/iot-with-aws-appsync/

iOS的sdk是 : https://github.com/aws-amplify/aws-sdk-ios

android的sdk是: https://github.com/aws-amplify/aws-sdk-android

传感器使用AWS IoT 设备 SDK连接到云中的AWS IoT Core并发布温度消息。
AWS IoT Core 接收消息并将它们转发到AWS Lambda函数。
Lambda 函数执行AWS AppSync GraphQL 突变,更新Amazon DynamoDB并将更改后的数据广播给移动应用程序订阅者。
移动应用程序接收数据并实时更新屏幕值。

如以下资料
https://docs.amplify.aws/lib-v1/graphqlapi/subscribe-data/q/platform/ios/

第二步搭建项目

准备工作
  1. 首先打开xcode创建项目 使用的是 Amplify v1 版本记住不要使用错了

项目的参数设置如下:


Product Name: input AmplifyDemo

Interface: select Storyboard

Language: Swift

点击next选择自己适合的位置

  1. iOS 项目打开选择 TARGETS->AmplifyDemo->General->Deployment Info, please select iOS 11.0

接下来要进行的是导入包操作,此步骤要等很久

打开电脑的终端 输入 cd 进入 以下是我的电脑信息

(1). 找到对应的创建文件夹进入(注意你得安装了 cocopads 安装教程: https://www.jianshu.com/p/fe4e1bf1c15d )


Last login: Fri Dec  2 09:18:50 on ttys001

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
ThermodeiMac:~ rnd$ cd /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo 
ThermodeiMac:AmplifyDemo rnd$ 

(2). 然后输入 pod init 进行文件夹创建


ThermodeiMac:~ rnd$ cd /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo 
ThermodeiMac:AmplifyDemo rnd$ pod init
ThermodeiMac:AmplifyDemo rnd$ 

(3). 进入AmplifyDemo 然后找到 Podfile文件打开输入以下的数据

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'AmplifyDemo' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for RilCompanySensor
  pod 'Amplify'
  pod 'SnapKit', '~> 5.0.0'
  pod 'AWSAppSync'
  pod 'AWSCore'
  pod 'AmplifyPlugins/AWSAPIPlugin'
  pod 'AmplifyPlugins/AWSCognitoAuthPlugin'

end

(4). 然后在控制台输入 pod install


ThermodeiMac:AmplifyDemo rnd$ pod install
Analyzing dependencies
Downloading dependencies
Installing AWSAppSync (3.6.1)
Installing AWSAuthCore (2.27.15)
Installing AWSCognitoIdentityProvider (2.27.15)
Installing AWSCognitoIdentityProviderASF (2.27.15)
Installing AWSCore (2.27.15)
Installing AWSMobileClient (2.27.15)
Installing AWSPluginsCore (1.26.2)
Installing Amplify (1.26.2)
Installing AmplifyPlugins (1.26.2)
Installing AppSyncRealTimeClient (1.10.0)
Installing ReachabilitySwift (5.0.0)
Installing SQLite.swift (0.12.2)
Installing SnapKit (5.0.1)
Installing Starscream (4.0.4)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `AmplifyDemo.xcworkspace` for this project from now on.
Pod installation complete! There are 6 dependencies from the Podfile and 14 total pods installed.

[!] Automatically assigning platform `iOS` with version `11.0` on target `AmplifyDemo` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] Amplify has added 1 script phase. Please inspect before executing a build. See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information.
ThermodeiMac:AmplifyDemo rnd$ 

(5). 到此创建iOS项目部分已经结束

  1. 打开我创建的项目下载下来里面有一个utils包

(1). 找到隐藏文件 .config打开 projectName:修改成你自己的项目名称

{
  "projectName": "AmplifyDemo",
  "version": "3.1",
  "frontend": "ios",
  "providers": [
    "awscloudformation"
  ]
}

(2) 把amplify文件夹拖到创建的iOS项目中

文件结构如下:

ThermodeiMac:~ rnd$ cd /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo/amplify 
ThermodeiMac:amplify rnd$ 

(3) 在终端输入命令 cd … 返回上一层目录

ThermodeiMac:~ rnd$ cd /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo/amplify 
ThermodeiMac:amplify rnd$ cd ..
ThermodeiMac:AmplifyDemo rnd$ 

(4) 操作这一步首先你得使你的电脑安装好 具体安装请参照以下官网链接 https://docs.amplify.aws/lib-v1/project-setup/prereq/q/platform/ios/ 以下步骤是整个项目最重要的部分

1> 默认是你已经全部安装完成

2> 在终端输入 sudo amplify init 根据我的操作按照如下进行,切莫忘记步骤


ThermodeiMac:AmplifyDemo rnd$ sudo amplify init
Password:
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the environment dosandbox //切记这个必须是2-10个字母
? Choose your default editor: (Use arrow keys)Visual Studio Code 
  Android Studio 
  Xcode (macOS only) 
  Atom Editor 
  Sublime Text 
  IntelliJ IDEA 
  Vim (via Terminal, macOS only) 
(Move up and down to reveal more choices)

? Choose your default editor: Visual Studio Code

Using default provider  awscloudformation
? Select the authentication method you want to use: 
  AWS profile 
❯ AWS access keys

? Select the authentication method you want to use: AWS access keys
? accessKeyId:  ********************
? secretAccessKey:  ****************************************

上面这个access key怎么找到呢,打开aws服务器点击你的名称选择 安全凭证

你的安全凭证:
点击选择 -> 访问密钥(访问密钥 ID 和秘密访问密钥)
如果没有的话自己创一个点击创建新的访问密钥然后记得下载下来保存好

接下来区域的选择 由于我选择的是国外的 所以我选择了 us-east-1 你的得按照自己的选择来选择

? region:  (Use arrow keys)
❯ us-east-1 
  us-east-2 
  us-west-1 
  us-west-2 
  eu-north-1 
  eu-west-1 
  eu-west-2 
(Move up and down to reveal more choices)

(5) 整个终端操作命令如下:


Note: It is recommended to run this command from the root of your app directory
? Enter a name for the environment dosandbox
? Choose your default editor: Visual Studio Code
Using default provider  awscloudformation
? Select the authentication method you want to use: AWS access keys
? accessKeyId:  ********************
? secretAccessKey:  ****************************************
? region:  us-east-1
Adding backend environment dosandbox to AWS Amplify app: d1jvkcwlhw9pvm

Deployment completed.
Deployed root stack AmplifyDemo [ ====================================
	amplify-amplifydemo-dosandbox… AWS::CloudFormation::Stack     CREATE_
	UnauthRole                     AWS::IAM::Role                 CREATE_
	AuthRole                       AWS::IAM::Role                 CREATE_
	DeploymentBucket               AWS::S3::Bucket                CREATE_

Deployment bucket fetched.Initializing your environment: dosandbox⠋ Building resource auth/sensorview74d✔ Initialized provider successfully.Initialized your environment successfully.

Your project has been successfully initialized and connected to the cloud!

Some next steps:
"amplify status" will show you what you've added already and if it's locally configured or deployed
"amplify add <category>" will allow you to add features like user login or a backend API
"amplify push" will build all your local backend resources and provision it in the cloud
"amplify console" to open the Amplify Console and view your project status
"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud

Pro tip:
Try "amplify add api" to create a backend API and then "amplify push" to deploy everything

ThermodeiMac:AmplifyDemo rnd$ 


(6) 创建的部分已经完成然后接下来还差一步就成功了继续在终端输入 sudo amplify push

Pro tip:
Try "amplify add api" to create a backend API and then "amplify push" to deploy everything

ThermodeiMac:AmplifyDemo rnd$ sudo amplify push

接下来你会看到这些请选择y


ThermodeiMac:AmplifyDemo rnd$ sudo amplify push
Password:
⠼ Fetching updates to backend environment: dosandbox from the cloud.⠋ Building r✔ Successfully pulled backend environment dosandbox from the cloud.

    Current Environment: dosandbox
    
┌──────────┬────────────────────┬───────────┬───────────────────┐
│ Category │ Resource name      │ Operation │ Provider plugin   │
├──────────┼────────────────────┼───────────┼───────────────────┤
│ Auth     │ sensorview74d21f87 │ Create    │ awscloudformation │
├──────────┼────────────────────┼───────────┼───────────────────┤
│ Api      │ sensorview         │ Create    │ awscloudformation │
├──────────┼────────────────────┼───────────┼───────────────────┤
│ Function │ getsensor          │ Create    │ awscloudformation │
├──────────┼────────────────────┼───────────┼───────────────────┤
│ Function │ createsensorvalue  │ Create    │ awscloudformation │
├──────────┼────────────────────┼───────────┼───────────────────┤
│ Iotrule  │ createsensorvalue  │ Create    │ awscloudformation │
└──────────┴────────────────────┴───────────┴───────────────────┘
? Are you sure you want to continue? (Y/n) y
? Are you sure you want to continue? Yes
GraphQL schema compiled successfully.

Edit your schema at /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo/amplify/backend/api/sensorview/schema.graphql or place .graphql files in a directory at /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo/amplify/backend/api/sensorview/schema
? Do you want to generate code for your newly created GraphQL API Yes
? Enter the file name pattern of graphql queries, mutations and subscriptions graphql/**/
? Do you want to generate/update all possible GraphQL operations - queries, mutations and subscrip
tions Yes
? Enter maximum statement depth [increase from default if your schema is deeply nested] 2
? Enter the file name for the generated code ApiHelp.swift


以上的每一步不要输错 部署的如以下


Deployment completed.
Deployed root stack AmplifyDemo [ ======================================== ] 6/6
	amplify-amplifydemo-dosandbox… AWS::CloudFormation::Stack     UPDATE_COMPLETE                Fri Dec 02 2022 1
	authsensorview74d21f87         AWS::CloudFormation::Stack     CREATE_COMPLETE                Fri Dec 02 2022 1
	functiongetsensor              AWS::CloudFormation::Stack     CREATE_COMPLETE                Fri Dec 02 2022 1
	apisensorview                  AWS::CloudFormation::Stack     CREATE_COMPLETE                Fri Dec 02 2022 1
	functioncreatesensorvalue      AWS::CloudFormation::Stack     CREATE_COMPLETE                Fri Dec 02 2022 1
	iotrulecreatesensorvalue       AWS::CloudFormation::Stack     CREATE_COMPLETE                Fri Dec 02 2022 1
Deployed auth sensorview74d21f87 [ ======================================== ] 11/11
	SNSRole                        AWS::IAM::Role                 CREATE_COMPLETE                Fri Dec 02 2022 1
	UserPool                       AWS::Cognito::UserPool         CREATE_COMPLETE                Fri Dec 02 2022 1
	UserPoolClient                 AWS::Cognito::UserPoolClient   CREATE_COMPLETE                Fri Dec 02 2022 1
	UserPoolClientWeb              AWS::Cognito::UserPoolClient   CREATE_COMPLETE                Fri Dec 02 2022 1
	UserPoolClientRole             AWS::IAM::Role                 CREATE_COMPLETE                Fri Dec 02 2022 1
	UserPoolClientLambda           AWS::Lambda::Function          CREATE_COMPLETE                Fri Dec 02 2022 1
	UserPoolClientLambdaPolicy     AWS::IAM::Policy               CREATE_COMPLETE                Fri Dec 02 2022 1
	UserPoolClientLogPolicy        AWS::IAM::Policy               CREATE_COMPLETE                Fri Dec 02 2022 1
	UserPoolClientInputs           Custom::LambdaCallout          CREATE_COMPLETE                Fri Dec 02 2022 1
	IdentityPool                   AWS::Cognito::IdentityPool     CREATE_COMPLETE                Fri Dec 02 2022 1
	IdentityPoolRoleMap            AWS::Cognito::IdentityPoolRolCREATE_COMPLETE                Fri Dec 02 2022 1
Deployed function getsensor [ ======================================== ] 3/3
Deployed function createsensorvalue [ ======================================== ] 4/4
	LambdaExecutionRole            AWS::IAM::Role                 CREATE_COMPLETE                Fri Dec 02 2022 1
	LambdaFunction                 AWS::Lambda::Function          CREATE_COMPLETE                Fri Dec 02 2022 1
	lambdaexecutionpolicy          AWS::IAM::Policy               CREATE_COMPLETE                Fri Dec 02 2022 1
	AmplifyResourcesPolicy         AWS::IAM::Policy               CREATE_COMPLETE                Fri Dec 02 2022 1
Deployed iotrule createsensorvalue [ ======================================== ] 2/2
	CreateSensorValueRule          AWS::IoT::TopicRule            CREATE_COMPLETE                Fri Dec 02 2022 1
	createsensorvalueallowIOTRule… AWS::Lambda::Permission        CREATE_COMPLETE                Fri Dec 02 2022 1Generated GraphQL operations successfully and saved at graphql
✖ EISDIR: illegal operation on a directory, read


GraphQL endpoint: https://xxxxxxxxx.appsync-api.us-east-1.amazonaws.com/graphql

GraphQL transformer version: 1

ThermodeiMac:AmplifyDemo rnd$ 


(7) 全部部署完成后你账号的资源应该包含

AppSync GraphQL API
DynamoDB表
Cognito用户池
Lambda函数(2)
物联网规则

(8) 确实以上步骤完成后请在终端输入 amplify codegen models
这个生成的model将会要导出来到你的项目中


ThermodeiMac:AmplifyDemo rnd$ sudo amplify codegen models
Password:
GraphQL schema compiled successfully.

Edit your schema at /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo/amplify/backend/api/sensorview/schema.graphql or place .graphql files in a directory at /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo/amplify/backend/api/sensorview/schema
Successfully generated models. Generated models can be found in /Users/Project/278161009/Github/Other/AWSServeiceTemperature/AmplifyDemo/amplify/generated/models
ThermodeiMac:AmplifyDemo rnd$ 

(9) 生成自动的swift查询代码运行 sudo amplify codegen types

ThermodeiMac:AmplifyDemo rnd$ sudo amplify codegen types
✔ Downloaded the schema
✔ Code generated successfully and saved in file ApiHelp.swift
ThermodeiMac:AmplifyDemo rnd$ 
开始部署iOS项目

目前为止你的项目配置已经全部完成接下来进入项目部分

  1. 进入AmplifyDemo 打开iOS项目 请选择 AmplifyDemo.xcworkspace

请添加图片描述

进入到项目中选择添加文件到项目 请选择“Add files to AmplifyDemo” 如下图所示 把 amplifyconfiguration 和 awsconfiguration 一起放入添加到项目中

然后再根据以上的添加方法把 amplify里面生成的generated的文件的models导入到你的项目中去
还有一个生成的 ApiHelp.swift一并导入项目

如图所示:

请添加图片描述

  1. 创建iOS的代码

此代码不重要的地方略过…

首先打开 AppDelegate.swift 导入包

import AWSAppSync
import Amplify
import AmplifyPlugins
import AWSMobileClient

然后接下添加注册

do{
            Amplify.Logging.logLevel = .verbose
            
            try Amplify.add(plugin: AWSAPIPlugin(modelRegistration: AmplifyModels()))
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.configure()
            //print("Amplify configured with auth plugin")
        }catch{
            print("An error occurred setting up Amplify: \(error)")
        }

进一步判断是否已经登录关键代码如果登录就直接进入Home界面没有进入登录界面再去注册账号

// 判断是否登录
        AWSMobileClient.default().initialize{
            (userState, error) in
            if let error = error {
                print("error: \(error.localizedDescription)")
                
                return
            }
            
            guard let userState = userState else {
                return
            }
            
            print("The user is \(userState.rawValue).")
            
            switch userState {
            case .signedIn:
                
                self.initializeAppSync()
                // 进入主界面
                let home = HomeViewController()
                let navCtrl = UINavigationController(rootViewController: home)
                self.window?.rootViewController = navCtrl
                self.window?.makeKeyAndVisible()
                break
            default:
                //界面跳转
                let login = LoginViewController()
                self.window?.rootViewController = login
                
                break
            }
        }

HomeViewController.swift

首先导入包

import AWSAppSync
import Amplify
import AmplifyPlugins
import SnapKit

关键代码获取 appSyncClient


guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
            return
        }

        appSyncClient = appDelegate.appSyncClient

还有注意 sensor-id:要去你自己的项目中查找

到此iOS代码已经结束请查看demo中的代码段

模拟温度探头的

进入项目中的 sensor文件中打开 create-senor.js文件

安装Node.js软件包,并运行Node.js应用程序,在AWS IoT Core中将传感器创建为Thing。它还将创建并安装传感器对物联网核心进行身份验证所需的证书。

从传感器文件夹中:

$ npm install
$ node create-sensor.js

*注意-这将使用您的默认AWS配置文件帐户和地区创建传感器。如果您没有在本地AWS配置中指定默认区域,它将默认为us-east-1。

如果您没有默认配置文件或使用的不是默认配置文件,请使用指定要使用的配置文件名称的AWS_PROFILE环境变量运行该应用程序。

将[my-aws-profile]替换为您的个人资料名称:

$ AWS_PROFILE=[my-aws-profile] node create-sensor.js

特别注意 :修改 //AWS_PROFILE=my-aws-profile node create-sensor.js
const PROFILE = process.env.AWS_PROFILE || ‘rnd’; 改成你自己命名的 因为这个与你的 accesskey是对应的

运行如下代码:


The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
ThermodeiMac:AWSServeiceTemperature rnd$ cd sensor
ThermodeiMac:sensor rnd$ node index.js
connected to IoT Hub
published to shadow topic $aws/things/sensor-1669959587928/shadow/update {"state":{"reported":{"sensorType":"Temperature"}}}
published to topic dt/sensor-view/sensor-1669959587928/sensor-value {"value":82,"timestamp":1669959722472}

结束

现在打开ios app 运行即可以看到以下界面
请添加图片描述
请添加图片描述
项目地址源代码在 https://github.com/ArdWang/AWSServeiceTemperature
欢迎查看给个star吧

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/54331.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

[附源码]JAVA毕业设计基于web的公益募捐网站(系统+LW)

[附源码]JAVA毕业设计基于web的公益募捐网站&#xff08;系统LW&#xff09; 目运行 环境项配置&#xff1a; Jdk1.8 Tomcat8.5 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目…

Apache JMeter压测工具

1.工具介绍 是什么 JMeter是一个软件&#xff0c;使负载测试或业绩为导向的业务&#xff08;功能&#xff09;测试不同的协议或技术。 Apache软件基金会的Stefano Mazzocchi JMeter的最初的开发。他写道&#xff1a;它主要对 Apache JServ&#xff08;现在称为如Apache Tomcat…

项目管理工具dhtmlxGantt入门教程(一):如何安装dhtmlxGantt

您可以使用 NuGet 、 Bower 或 npm 包管理器将 dhtmlxGantt 包安装到您的项目中,也可以从 CDN 中包含必要的 JS/CSS 文件。 DhtmlxGantt正版试用下载&#xff08;qun&#xff1a;764148812&#xff09;https://www.evget.com/product/4213/download NuGet 安装 dhtmlxGantt …

C++使用gRPC实例

什么是gRPC RPC 即远程过程调用协议&#xff08;Remote Procedure Call Protocol&#xff09;&#xff0c;可以让我们像调用本地对象一样发起 远程调用。RPC 凭借其强大的治理功能&#xff0c;成为解决分布式系统通信问题的一大利器。 gRPC是一个现代的、高性能、开源的和语言…

Python数据分析实战-实现一维列表(数组)和多维列表(数组)的相互转化(附源码和实现效果)

前面我介绍了可视化的一些方法以及机器学习在预测方面的应用&#xff0c;分为分类问题&#xff08;预测值是离散型&#xff09;和回归问题&#xff08;预测值是连续型&#xff09;&#xff08;具体见之前的文章&#xff09;。 从本期开始&#xff0c;我将做一个数据分析类实战…

[附源码]计算机毕业设计springboot校园疫情管理系统

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

文件的上传与下载

文章目录一、 实验目的&#xff1a;二、实验要求&#xff1a;三、实验内容&#xff1a;1、单文件上传2、多文件上传3、上传文件的大小限定4、实现文件的下载功能&#xff0c;并解决下载乱码问题一、 实验目的&#xff1a; 掌握Servlet的HttpServletRequest对文件上传的支持&am…

内存管理---分页机制

目录 物理内存管理带来的问题 直接映射 一级页表 二级页表 参考&#xff1a; &#xff08;C语言内存七&#xff09;分页机制究竟是如何实现的&#xff1f; - Smah - 博客园 物理内存管理带来的问题 比如4GB的flash, 如果应用程序可直接访问物理内存&#xff0c;那么可能一个…

云小课|基于华为云WAF的日志运维分析,构筑设备安全的城墙

阅识风云是华为云信息大咖&#xff0c;擅长将复杂信息多元化呈现&#xff0c;其出品的一张图(云图说)、深入浅出的博文(云小课)或短视频(云视厅)总有一款能让您快速上手华为云。更多精彩内容请单击此处。 摘要&#xff1a;云日志服务用于收集来自主机和云服务的日志数据&#x…

windows安装docker版青龙面板

1.下载docker Docker Desktop 官方下载地址&#xff1a; windows docker 2 管理员运行PowerShell&#xff0c;执行下面的命令(Hyper-V 和容器特性) Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All3.运行第一步下载好的exe 双击下载的 Docker fo…

springboot基于vue.js的掌上博客系统的设计与实现毕业设计源码063131

Springboot掌上博客系统的设计与实现 摘 要 掌上博客系统是当今网络的热点&#xff0c;博客技术的出现使得每个人可以零成本、零维护地创建自己的网络媒体&#xff0c;Blog站点所形成的网状结构促成了不同于以往社区的Blog文化&#xff0c;Blog技术缔造了“博客”文化。 本文课…

恶补了 Python 装饰器的八种写法,你随便问~

对于每一个学习 Python 的同学&#xff0c;想必对 符号一定不陌生了&#xff0c;正如你所知&#xff0c; 符号是装饰器的语法糖&#xff0c;符号后面的函数就是我们本文的主角&#xff1a;装饰器。 装饰器放在一个函数开始定义的地方&#xff0c;它就像一顶帽子一样戴在这个…

Java---File详解

目录 一、File的概述 二、File的创建 三、File的常见成员方法 1&#xff1a;判断和获取 2&#xff1a;创建和删除 &#xff08;1&#xff09;createNewFile() &#xff08;2&#xff09;mkdir() &#xff08;3&#xff09;delete&#xff08;&#xff09; 3&#xff1a…

高新技术企业认定条件

主要是评估企业的以下几个条件&#xff1a; 一是企业成立满一年以上&#xff0c;并且符合高企八大领域&#xff1b; 二是拥有核心自主知识产权&#xff0c;并且近一年高新产品的收入啊&#xff0c;需要占总收入的60%以上&#xff1b; 三是科技人员占当年职工总数的比例不低于…

mybatis学习:四、关联查询、缓存

7. 关联查询 7.1 准备工作: 数据库表: #订单表&#xff1a; create table tb_order (id INT AUTO_INCREMENT PRIMARY KEY,userid INT,createtime DATETIME,state VARCHAR(20) ) ENGINEInnoDB AUTO_INCREMENT1;#订单详情表 CREATE TABLE tb_orderdetail(…

[附源码]Python计算机毕业设计SSM酒店式公寓服务系统(程序+LW)

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

[LeetCode 1769]移动所有球到每个盒子所需的最小操作数

题目描述 题目链接&#xff1a;[LeetCode 1769]移动所有球到每个盒子所需的最小操作数 有 n 个盒子。给你一个长度为 n 的二进制字符串 boxes &#xff0c;其中 boxes[i] 的值为 ‘0’ 表示第 i 个盒子是 空 的&#xff0c;而 boxes[i] 的值为 ‘1’ 表示盒子里有 一个 小球。…

Gradle简单配置

写在前面&#xff1a;一开始配置gradle的时候&#xff0c;最好不要把他maven仓库配置在一起&#xff0c;前段时间配置公司项目身心俱疲。大部分公司里面用gradle都是配置的自己的仓库地址&#xff0c;所以有的东西就不要和网上的配置保持一致了&#xff0c;比如说这个仓库地址。…

网站都变成灰色了,它是怎么实现的?

大家好&#xff0c;我是二哥呀。 想必大家都感受到了&#xff0c;很多网站、APP 在昨天都变灰了。 先来感受一下变灰后的效果。 这种灰色的效果怎么实现的呢&#xff1f;如何做到图片、文字、按钮都变灰的效果呢&#xff1f; 方案 1&#xff0c;换一套灰色的 UI&#xff0c;…

Github限时开源24小时,Alibaba架构师内部最新发布SpringCloud开发手册

前言 微服务是SOA之后越来越流行的体系结构模式之一&#xff01; 如果您关注行业趋势&#xff0c;就会发现,如今商业机构不再像几年前那样&#xff0c;开发大型应用程序&#xff0c;来管理端到端之间的业务功能&#xff0c;而是选择快速灵活的微服务。 ​ 通过微服务&#x…