小编Cly*_*row的帖子

Firebase - 如何从控制台设置自定义声明

在我的应用程序中,我使用 firebase 身份验证和 Google 帐户作为凭据提供程序。我想为用户分配角色。为了做到这一点,我想向用户在登录期间获得的身份验证令牌添加自定义声明。这是我的问题,因为我不知道如何从 firebase 控制台向现有用户添加声明。

firebase firebase-authentication firebase-console

13
推荐指数
1
解决办法
2685
查看次数

JDK17 + Spring Boot Starter Web 服务:在模块路径或类路径上未找到 JAXB-API 的实现

我有一个简单的 Spring Boot 应用程序,我想将请求发送到 SOAP 端点。不幸的是,每次我尝试这样做时,我都会收到:javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath。我非常有信心我拥有所有必需的库,但我不知道为什么会发生这种情况

Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:177)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:364)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:508)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:465)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:366)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.createJaxbContextFromContextPath(Jaxb2Marshaller.java:540)
    at org.springframework.oxm.jaxb.Jaxb2Marshaller.getJaxbContext(Jaxb2Marshaller.java:500)
    ... 18 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
    at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:174)
    ... 24 common frames omitted
Run Code Online (Sandbox Code Playgroud)

我使用的是JDK17

openjdk 17.0.2 2022-01-18
OpenJDK …
Run Code Online (Sandbox Code Playgroud)

java spring-ws jaxb spring-oxm spring-boot

8
推荐指数
1
解决办法
2万
查看次数

如何将Apache Airflow与Slack集成在一起?

有人可以给我逐步指南,介绍如何将Apache Airflow连接到Slack工作区。我为频道创建了webhook,接下来该怎么做?

亲切的问候

apache slack airflow

7
推荐指数
3
解决办法
5434
查看次数

如何对使用分层方法的Lambda逻辑进行单元测试?

嗨,我有我的AWS Lambda,我想在上面添加一个图层。我希望能够仅测试lambda的单个方法。但是,他们中的许多人都使用层逻辑,因此在我看来这并不容易。最好的方法是什么?

一种方法是打包层,将主机放置在某个地方并将其用作依赖项。在那种情况下,为什么还要费心使用图层呢?

我的另一个想法是使用sam-cli在本地部署lambda。我知道如何使用它来测试整个lambda逻辑,但是我看不到如何分别对测试方法进行单元测试; /您的经验是什么?KR

编辑。我的解决方案

  • 添加pytest

  • 将所有测试放在test目录中

  • 添加调用测试的测试lambda处理程序

import pytest def lambda_handler(event, _): res = pytest.main(['-x', './tests']) return res

  • 添加template.yml指向先前创建的lambda处理程序

Resources: MyFunction: Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction Properties: CodeUri: src/ Handler: test.lambda_handler Runtime: python3.6 Events: MyInfo: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /my-service/test Method: get Environment: Variables: ELASTICSEARCH_DOC_TYPE: "article" ELASTICSEARCH_INDEX: "artilces" ELASTICSEARCH_HOST: "elastic" ELASTICSEARCH_PORT: "9200" ELASTICSEARCH_URL: "http://my_elastic.com:9200" Layers: - arn:aws:lambda:eu-west-1:XXXXXXXXXXXXX:layer:lambda_layer:37

  • 跑 sam local invoke --no-event

amazon-web-services aws-lambda aws-sam-cli aws-sam

6
推荐指数
2
解决办法
633
查看次数

SQLAlchemy + MySQL - 将表名作为原始查询中的参数传递

在我的应用程序中,我使用 SQLAlchemy 和 mysql-connector-python。我想SELECT * FROM :table LIMIT 10在我的 mysql 数据库上执行这样的查询。但是我的代码不起作用

table_name = "tmp1"
QUERY = "SELECT * FROM :table LIMIT 10"
conn = create_sql_connection()
res = conn.execute(
    QUERY,
    {'table': table_name}
).fetchall()
print(res)
Run Code Online (Sandbox Code Playgroud)

我读到你不能使用表名作为参数,我应该只使用 python 字符串格式。但我真的很担心它绝对不能安全地防止 sql 注入。怎么解决呢?是否有任何实用程序可以转义我的表名变量?

Postgres 有一个解决方案 -在 psycopg2 中传递表名作为参数- 你知道在使用 mysql 时如何解决它吗?

python sqlalchemy

6
推荐指数
1
解决办法
4139
查看次数

如何将 Flux<List<T>> 展平为 Flux<T>?

嗨,我的代码如下所示:

fun mapBatch(batch: List<String>): Mono<List<MyClass>> ...

fun myFun(stream: Flux<String>): Flux<MyClass> {
    return stream
            .bufferTimeout(50, Duration.ofSeconds(60L))
            .flatMap{ batch -> mapBatch(batch) }
            /// now here I would like to get Flux<MyClass> but have Flux<List<MyClass>> 
}
Run Code Online (Sandbox Code Playgroud)

Flux<T>如何获得Flux<List<T>>?

java spring project-reactor spring-webflux

6
推荐指数
1
解决办法
8184
查看次数

SQL Server JDBC的驱动程序类名称是什么

我想将我的Java SpringBoot应用程序连接到SQL Server,并且得到有关spring无法加载驱动程序类的信息。我试过了:

spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
Run Code Online (Sandbox Code Playgroud)

和

spring.datasource.driver-class-name=com.microsoft.jdbc.sqlserver.SQLServerDriver
Run Code Online (Sandbox Code Playgroud)

但是两者都没有用,这是我的Maven依赖

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>7.0.0.jre8</version>
    <scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

java sql-server spring

5
推荐指数
1
解决办法
7731
查看次数

Docker上的SpringBoot AMPQ不能总是连接到队列

我有一个SpringBoot应用程序,我想连接到Rabbit MQ并阅读一些消息。但是我确实有一个问题,当我部署应用程序时,有时它会立即连接到Rabbit并开始工作,但更多时候它只会尝试连接并尝试,最后我收到超时异常,如下所示:

2018-10-17 09:03:54.460 ERROR 15 --- [ main] o.s.a.r.l.SimpleMessageListenerContainer : Consumer failed to start in 60000 milliseconds; does the task executor have enough threads to support the container concurrency?
Run Code Online (Sandbox Code Playgroud)

我使用AWS ECS,因此我的应用程序在docker容器中运行。可能相关吗?

这是我的配置,所有这些环境变量均有效

spring.rabbitmq.host=${RABBIT_HOST}
spring.rabbitmq.port=${RABBIT_PORT}
spring.rabbitmq.username=${RABBIT_USERNAME}
spring.rabbitmq.password=${RABBIT_PASSWORD}
spring.rabbitmq.virtualHost=${RABBIT_HOST}
rabbitmq.queues=myQueue
Run Code Online (Sandbox Code Playgroud)

还有我的代码

@Component
@Slf4j
@RequiredArgsConstructor
final class ListingMessageListener {

    private final BackOfficeService backOfficeService;

    @RabbitListener(queues = "${rabbitmq.queues}")
    public void receiveMessage(final ListingMessage listingMessage) {
        final String listingId = listingMessage.getMessage().getListingId();
        log.info("Received listingId= {}", listingId);            
Optional.ofNullable(backOfficeService.getOfferById(Long.valueOf(listingId))).ifPresent(offer -> log.info(offer.getName()));

    }
}
Run Code Online (Sandbox Code Playgroud)

java rabbitmq spring-amqp docker spring-boot

5
推荐指数
0
解决办法
373
查看次数

React Bootstrap + Formik - 单击提交按钮后显示错误

在我的应用程序中,我使用 React Bootstrap 和 Formik。我希望引导程序在我按下提交按钮后显示该字段无效(例如不是电子邮件,但应该是)。然后当我开始在字段中输入新值时,它应该会消失。在我使用的教程中,我只找到了在用户输入值的同时显示该字段无效的方法?

怎么做?如何设置isInvalid仅在使用 Formik 提交后才显示错误?

这是我当前的代码

import * as yup from "yup";
import React from "react";
import Form from "react-bootstrap/Form";
import Button from "react-bootstrap/Button";
import {Formik} from "formik";
import {loginActions} from "../_actions/loginActions";
import {connect} from "react-redux";
import {loginService} from "../_services";

const schema = yup.object().shape({
    username: yup.string().email("Login musi by? w formie e-mail").required("Wype?nij pole login"),
    password: yup.string().required("Wype?nij pole has?o")
});

class LoginForm extends React.Component {

    constructor(props) {
        super(props);
        this.handleSubmit = this.handleSubmit.bind(this);
    }

    handleSubmit(e) {
        const {username, password} …
Run Code Online (Sandbox Code Playgroud)

reactjs react-bootstrap formik

5
推荐指数
1
解决办法
7750
查看次数

Spring Actuator + Kafka Streams - 将 kafka 流状态添加到健康检查端点

我有一个使用 apache kafka-streams 的 Spring Boot 应用程序。我不使用 spring 云流。我添加了执行器健康检查端点。我是application.yml这样配置的:

management:
  health.db.enabled: false
  endpoints.web:
    base-path:
    path-mapping.health: /
Run Code Online (Sandbox Code Playgroud)

当抛出运行时异常并且我的流被停止时,日志显示但运行状况检查状态为 UP。

2019-09-17 13:16:31.522 INFO 1 --- [ Thread-5] org.apache.kafka.streams.KafkaStreams : stream-client [lpp-model-stream-7e6e8fea-fcad-4033-92a4-5ede50de6e17] Streams client stopped complet伊利

如何将 kafka 流状态绑定到健康检查端点?

我的 pom.xml:

  <dependencies>
            <dependency>
                <groupId>org.springframework.kafka</groupId>
                <artifactId>spring-kafka</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.kafka</groupId>
                <artifactId>kafka-streams</artifactId>
            </dependency>
            <dependency>
                <groupId>data-wizards</groupId>
                <artifactId>lpp-common-avro</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <dependency>
                <groupId>io.confluent</groupId>
                <artifactId>kafka-streams-avro-serde</artifactId>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
            </dependency>
            <dependency> …
Run Code Online (Sandbox Code Playgroud)

spring apache-kafka spring-boot

5
推荐指数
1
解决办法
5122
查看次数