我正在按照本指南使用 Spring 构建 RESTful Web 服务。我正在使用 grable 来构建应用程序,但我的构建失败了。
我在 Windows 10 机器上使用了“build gradle”命令。
这是gradle代码:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile('org.springframework.boot:spring-boot-starter-test')
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
任务 ':bootJar' 执行失败。
主类名未配置,无法解析
当我尝试运行我的lxc
容器时,我得到:
lxc-start: 100: lxccontainer.c: wait_on_daemonized_start: 751 No such file or directory - Failed to receive the container state
lxc-start: 100: tools/lxc_start.c: main: 371 The container failed to start.
lxc-start: 100: tools/lxc_start.c: main: 373 To get more details, run the container in foreground mode.
lxc-start: 100: tools/lxc_start.c: main: 375 Additional information can be obtained by setting the --logfile and --logpriority options.
Run Code Online (Sandbox Code Playgroud)
我的lxc
配置:
#WEBSERVER
arch: amd64
cores: 1
hostname: poseidon
memory: 2048
net0: name=eth0,bridge=vmbr0,gw=192.168.0.1,hwaddr=66:79:16:C7:C3:51,ip=192.168.0.12/24,type=veth
onboot: 1
ostype: debian …
Run Code Online (Sandbox Code Playgroud) 以下代码创建一个 firestore 集合并向其添加数据:
function saveID(sender_psid,complete){
let data = new Object();
data.ID = sender_psid;
data.TASK = complete;
data.TIME = new Date();
db.collection('users').add(data);
}
Run Code Online (Sandbox Code Playgroud)
我想创建另一个函数,在不同的时间向文档添加一个字段。我有以下函数,但收到错误“TypeError:collectionRef.update 不是函数”
function saveImage(sender_psid,image) {
let collectionRef = db.collection('users');
collectionRef.update({IMG:image}).then(res => {
console.log(`Document updated at ${res.updateTime}`);
});
}
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
function saveID(sender_psid,complete){
let data = new Object();
data.TASK= complete;
data.ID = sender_psid;
db.collection('users').add(data);
}
Run Code Online (Sandbox Code Playgroud)
现在,每次更新字段完成时都会创建一个新文档。我想更新 firestore 中的complete值,而不是每次都创建一个新文档。
我已将一个node js
快递项目上传到AWS lambda
. 以下是我保存为的处理程序代码exports.js
:
const
express = require('express'),
bodyParser = require('body-parser'),
request = require('request'),
app = express().use(bodyParser.json()); // creates express http server
exports.handler = function(callback){
request('http://localhost/php-rest/api.php/routes?filter=route_short_name', function(error, response, body) {
if (!error && response.statusCode == 200) {
message = JSON.stringify(JSON.parse(body));
return callback(message, false);
} else {
return callback(null, error);;
}
});
}
app.get('/exports.handler', function(req, res) {
exports.handler(function(err, data){
if(err) return res.send(err);
res.send(data);
});
});
Run Code Online (Sandbox Code Playgroud)
处理程序代码与我的app.js
文件分开。在 aws lambda 上测试时出现以下错误:
{
"errorMessage": "Handler 'handler' …
Run Code Online (Sandbox Code Playgroud) javascript ×3
node.js ×3
firebase ×2
aws-lambda ×1
gradle ×1
lxc ×1
proxmox ×1
spring ×1
zfs ×1