我正在尝试使用 Spring Boot 和 Dialogflow 在 google 上创建操作。我试图在其中使用可用的 java 库https://github.com/actions-on-google/actions-on-google-java
但无法理解我应该如何在 Spring Boot 应用程序中实现这些注释。例如:@ForIntent
我已经尝试使用 App Engine 入口点https://github.com/actions-on-google/dialogflow-webhook-boilerplate-java的样板代码 我能够运行此代码,但无法理解其在 Spring Boot 中的实现应用。
在 Spring Boot 中:我们在应用程序中使用 @RestController 来映射请求
但是对于 google 上的操作,只会有一个请求链接,我们可以提供 Fulfillment webhook。那么我应该在哪里使用代码中的@ForIntent 来识别 Intent 并更改请求正文和响应正文。
我有以下格式的传入字符串:“ LARGE:34,MEDIUM:25,SMALL:15”
我有以下课程:
public class Portion_Price
{
[DataMember]
public PortionSize PortionSize { get; set; }
[DataMember]
public Decimal ItemPrice { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想通过分割字符串来分配PortionSize和ItemPrice。以下是我的工作代码:
str_portion_price = "LARGE:34,MEDIUM:25,SMALL:15";
List<Portion_Price> Portion_Price_List = new List<Portion_Price>();
if (!String.IsNullOrEmpty(str_portion_price))
{
List<string> str_por_pri = str_portion_price.Split(',').ToList();
foreach (var str_port_pric in str_por_pri)
{
Portion_Price single_portion_price = new Portion_Price();
List<string> portion_price = str_port_pric.Split(':').ToList();
single_portion_price.PortionSize = (PortionSize)Enum.Parse(typeof(PortionSize), portion_price[0]);
single_portion_price.ItemPrice = Convert.ToDecimal(portion_price[1]);
Portion_Price_List.Add(single_portion_price);
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,但我想以Linq方式或其他任何较短的方式使其更具可读性。还有其他方法可以做到这一点吗?
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.loader.MultipleBagFetchException: 不能同时取多个包: [Order.items, OrderItem.options];
以上是我加入如下三个表时遇到的一个例外。
订单项选项.java
@Entity
public class OrderItemOption {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "item_option_id")
private Long id;
@Column(name = "item_id", nullable = false)
private Long itemId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(
name = "item_id",
referencedColumnName = "item_id",
insertable = false,
updatable = false
)
private OrderItem orderItem;
}
Run Code Online (Sandbox Code Playgroud)
订单项.java
@Entity
public class OrderItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "item_id")
private Long id;
@Column(name = "order_id", nullable = false)
private Long orderId;
@ManyToOne(fetch = FetchType.LAZY) …
Run Code Online (Sandbox Code Playgroud) 我创建了一个数据库,然后尝试将该数据库包含到另一个创建的库中。构建良好,但收到-“未在output.globals中为外部模块'my-data'提供名称-猜测'myData'”。我想念什么?
完成重新创建的步骤。
my-core.module.ts
import { NgModule } from '@angular/core';
import { MyCoreComponent } from './my-core.component';
import { MyDataModule } from 'my-data';
@NgModule({
declarations: [MyCoreComponent],
imports: [MyDataModule],
exports: [MyCoreComponent]
})
export class MyCoreModule { }
Run Code Online (Sandbox Code Playgroud)
I decided to use React hooks for my component using windom width and resize event listener. The problem is that I can't access current value that I need. I get nested value that was set while adding event listener.
Passing function to value setter function is not a solution for me because it's forcing render and breaking my other functionalities.
I am attaching minimalistic example to present core problem:
import React, { Component, useState, useEffect } from 'react';
import { …
Run Code Online (Sandbox Code Playgroud) 我创建了一个基本的节点应用程序,其顶部带有打字稿。我正在使用 ts-node 来执行此操作,并且它与 nodemon 一起工作完全正常。但我现在需要将其移至服务器,我陷入困境。PM2一直显示错误。我已经浏览了 GitHub 和 StackOverflow 上的其他答案。这里没有任何帮助我。请帮忙。
\n\n我尝试使用 PM2 安装 typescript 和 ts-node。但它对我不起作用。我也尝试过直接运行文件,但没有成功。我现在不知道该如何解决这个问题。
\n\n "scripts": {\n "start": "nodemon -x ts-node src/server.ts"\n },\n
Run Code Online (Sandbox Code Playgroud)\n\n使用简单的 npm run start 命令就可以正常工作
\n\nmadbo@DESKTOP-CS5UFKE MINGW64 /e/shailesh/nodejs/NodeType\n$ npm run start\n\n> NodeType@1.0.0 start E:\\shailesh\\nodejs\\NodeType\n> nodemon -x ts-node src/server.ts\n\n[nodemon] 1.18.5\n[nodemon] to restart at any time, enter `rs`\n[nodemon] watching: *.*\n[nodemon] starting `ts-node src/server.ts`\n24 Mar 22:33:23 - listening on port 3000\nMongoose default connection is open to mongodb://localhost:27017/todo \n\n
Run Code Online (Sandbox Code Playgroud)\n\n到目前为止我所尝试的方法都不起作用 *(PM2已全局安装)*
\n\npm2 start ts-node -- …
Run Code Online (Sandbox Code Playgroud) function openFileDialog() {
dialog.showOpenDialog(win, {
properties: ['openFile']
} , filepath => {
if (filepath) {
fs.writeFile('path.txt', filepath, function (err, data) {
if (err) console.log(err);
});
scanFile(filepath)
}
})
}
function scanFile(filepath) {
if(!filepath || filepath[0] == 'undefined') return;
console.log(filepath)
fs.readFile(filepath,"utf8", (err,data) => { // ----> *ERROR*
if(err) console.log(err);
var arr = [];
if (data.substr(-4) === '.mp3' || data.substr(-4) === '.m4a'
|| data.substr(-5) === '.webm' || data.substr(-4) === '.wav'
|| data.substr(-4) === '.aac' || data.substr(-4) === '.ogg'
|| data.substr(-5) === '.opus') …
Run Code Online (Sandbox Code Playgroud) 考虑以下集成测试注释:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = "spring.main.allow-bean-definition-overriding=true")
@ContextConfiguration(classes = {WorkerTestConfig.class})
//@Import(value = {WorkerTestConfig.class})
@ActiveProfiles({"dev","test"})
public class NumberServiceITest {
Run Code Online (Sandbox Code Playgroud)
WorkestTestConfig 的作用是在集成启动期间覆盖真实 bean/一组 bean,每当我使用@ContextConfiguration
真实 bean 时,真实 bean 就会退出并使用 WorkerTestConfig 中的 bean,每当我使用真实 bean 时,@Import
仍然会创建真实 bean 并导致测试失败。
它WorkerTestConfig
本身尽可能简单:
@TestConfiguration
public class WorkerTestConfig {
@Primary
@Bean
public ScheduledExecutorService taskExecutor() {
return DirectExecutorFactory.createSameThreadExecutor();
}
}
Run Code Online (Sandbox Code Playgroud)
谁能解释一下 @SpringBootTest 注释的另一个神奇行为?如果您重现相同的行为,请确认,以便我可以转到问题跟踪器,因为我已经看到人们在此处
使用@Import
with ,并且在 Spring Boot 文档中没有任何内容禁止它:https: //docs.spring.io/spring-boot/文档/current/reference/html/boot-features-testing.html#boot-features-testing-spring-boot-applications-排除-config@SpringBootTest
完全不知道发生了什么。
版本:2.1.2.RELEASE
更新:
还尝试删除真正的bean,看看问题是否只是覆盖,但@Import
注释只是死在水中,不起作用 - >甚至无法创建bean,@ContextConfiguration具有附加/覆盖行为,导入在全部。注释的完全限定导入是: import org.springframework.context.annotation.Import;
也试图从 到 …
我有 DNA 序列数据。例如,
X="ACGGGT"
Y="ACGGT"
Run Code Online (Sandbox Code Playgroud)
我想知道对齐分数,因此我使用了biopythonpairwise2函数。例如,
from Bio import pairwise2
from Bio.pairwise2 import format_alignment
alignments = pairwise2.align.globalxx(X, Y)
for a in alignments:
print(format_alignment(*a))
Run Code Online (Sandbox Code Playgroud)
这成功地显示了 DNA 比对,但我只需要如下的分数。有没有办法只显示分数?
我使用了biopython,但如果有更好的方法,我们将不胜感激。
I just upgrade Cordova to version 9. It cased plugin cordova-plugin-crypt-file to stop working - when I build the application, I get error
Using "requireCordovaModule" to load non-cordova module "path" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
Run Code Online (Sandbox Code Playgroud)
It looks like the issue is with file hooks/after_prepare.js. The code is
var path = context.requireCordovaModule('path'),
fs = context.requireCordovaModule('fs'),
crypto = context.requireCordovaModule('crypto'),
Q = context.requireCordovaModule('q'),
cordova_util = context.requireCordovaModule('cordova-lib/src/cordova/util'),
platforms = context.requireCordovaModule('cordova-lib/src/platforms/platforms'),
Parser = …
Run Code Online (Sandbox Code Playgroud) java ×2
javascript ×2
node.js ×2
spring-boot ×2
angular ×1
angular7 ×1
biopython ×1
c# ×1
class ×1
cordova ×1
dna-sequence ×1
electron ×1
fs ×1
hibernate ×1
jpa ×1
linq ×1
module ×1
pairwise ×1
pm2 ×1
python ×1
querydsl ×1
react-hooks ×1
reactjs ×1
require ×1
split ×1
spring ×1
ts-node ×1
typescript ×1