我正在尝试从集合中查询一些文档,此查询应该侦听在查询文档中所做的更改,因此我需要一个流。我正在关注(在 Dart/Flutter 中)
Stream<List<MatchRequest>> _getNewMatches() {
return Collection<MatchRequest>(path: 'requests')
.ref
.where('status', isNull: true)
.where('users', arrayContains: ['$currentUid'])
.orderBy('last_activity')
.snapshots()
.map((list) => list.documents.map(
(doc) => Global.models[MatchRequest](doc.data) as MatchRequest));
}
Run Code Online (Sandbox Code Playgroud)
(对象 Collection 在它的构造函数中设置 ref 的路径,例如:ref = db.collection($path) 并且地图制作结果模型)
然后我使用 StreamBuilderstream调用上面的方法并builder检查快照.hasData 。但它一直在加载,snapshot.hasData 一直是假的。我在这里做错了什么?
编辑:
我的 Firestore 安全规则包含:
match /requests/{requestId} {
allow read: if isLoggedIn();
allow write: if isLoggedIn();
}
Run Code Online (Sandbox Code Playgroud)删除每个where和时orderBy,它也找不到任何东西。并且请求集合中存在文档
当尝试从请求集合中仅查询 1 个文档作为流时,他确实找到了结果
是因为我应该向 Firestore 索引添加索引吗?但这并不能解决我的第一个问题,即即使没有whereand orderBy,它也不会获得任何数据
我在我的 pom.xml 依赖项中使用 version: 2.1.6.RELEASE form Spring Boot。为了连接到我的数据库,我在 application.properties 中放置了以下内容:
spring.datasource.url= jdbc:postgresql://
spring.datasource.username=
spring.datasource.password=
Run Code Online (Sandbox Code Playgroud)
检查 postgresql 中的连接数量时:
SELECT * FROM pg_stat_activity;
Run Code Online (Sandbox Code Playgroud)
每次启动应用程序时,我都会看到正好建立了 10 个连接。他们几乎都有相同的查询:
SET application_name = 'PostgreSQL JDBC Driver'
Run Code Online (Sandbox Code Playgroud)
有没有办法阻止应用程序进行那么多连接?我应该自己做池配置吗?我的 Java 应用程序中的哪些资源会初始化这些连接?
我唯一能想到的是我使用@Autowired 注释创建 EntityManager(s),EntityManager 来自:
javax.persistence.EntityManager;
Run Code Online (Sandbox Code Playgroud)
但是我读到您应该只关闭在使用 EntityManagerFactory 时建立的连接。注释应该关闭连接。
如果您需要更多信息,我可以编辑我的帖子
指南: https ://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SSL-on-amazon-linux-2.html
问题:
我必须在exact-online 和其他网站之间进行集成。为此,我在 Amazon linux 2 EC2 服务器上运行一个 java 后端,并使用控制器方法来监听精确的在线 webhook。我从 webhook 获取信息并使用他们的 api 将其发送到其他网站。所以我没有任何人可以访问的实际网页,这只是一个“内部”程序。
现在对于 webhook 我的控制器如下所示:
@RequestMapping(value = "/WebHook", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<?> webhook(@RequestBody(required = false) ExactWebHookResponse exactWebHookResponse) {
// handle exactWebHookResponse
return new ResponseEntity<Object>(HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
Webhook 仅通过“https”协议进行通信。所以我的控制器应该监听对 https://{Elastic-IP}/WebHook 发出的 webhook 请求。
为了在 Amazon 服务器上初始化 SSL/TLS,我遵循了上述指南;我安装了 Apache,配置了我的安全组等。一切都很顺利,直到我尝试使用 LetsEncrypt-Certbot 获取 CA 证书。当我尝试获取域的证书时:{Elastic-IP} 它告诉我他们不向 IP 地址提供证书。因此,我尝试使用我的公共 DNS:ec2-{Elastic-IP}.us-east-2.compute.amazonaws.com,但他们不向“amazonaws.com”域提供证书。
我对 SSL/TLS 和证书一点也不熟悉,那么我在这里做错了什么?
我正在这样导入AsyncSorage:
import { AsyncStorage } from '@react-native-community/async-storage'
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我正在执行以下操作:
AsyncStorage.setItem('locale', locale)
Run Code Online (Sandbox Code Playgroud)
和这个:
AsyncStorage.getItem('user').then((value) => {
Run Code Online (Sandbox Code Playgroud)
它们都给我以下错误:
TypeError:undefined不是对象(评估'_asyncStorage.AsyncStorage.setItem')
TypeError:undefined不是对象(评估'_asyncStorage.AsyncStorage.getItem')
当我从'react-native'导入AsyncStorage时,没有问题,只是说应该从'@ react-native-community'导入AsyncStorage,因为不推荐使用'react-native'的AsyncStorage。
PS:我知道我应该await在AsyncStorage之前使用,但这不能解决问题。
我的@ react-native-community / async-storage版本如下:
"@react-native-community/async-storage": "^1.6.1"
我已经尝试卸载并重新安装@ react-native-community / async-storage依赖项,但是没有用。
我已经尝试在它前面放一个等待,但这给了我同样的错误
我已经尝试过搜索它,但是没有找到任何解决方案。
该屏幕的完整代码:
import React from 'react';
import { View, Image, NativeModules } from 'react-native';
import { AsyncStorage } from '@react-native-community/async-storage'
import { styles } from '../../components/Styles.js';
import { GEOLocation } from '../../scripts/GEOLocation';
import Moment from 'moment/min/moment-with-locales';
export default class SplashScreen extends React.Component {
constructor(props) {
super(props);
this.geo …Run Code Online (Sandbox Code Playgroud) asyncstorage ×1
certificate ×1
firebase ×1
flutter ×1
hikaricp ×1
java ×1
jdbc ×1
react-native ×1
spring-boot ×1
stream ×1