小编Bil*_*lly的帖子

OpenShift Origin 4.X的时间表是什么?

我的公司正在与OKD合作。我有一个问题,何时可以向公众提供4.1版。在这方面的任何评论将不胜感激。

okd

6
推荐指数
0
解决办法
120
查看次数

无法使用 quarkus 注入配置属性

我正在尝试从 Spring 迁移现有应用程序,但遇到了一些问题。我的 application.properties 中有这个:

sms.gateway.pinLength = 5
Run Code Online (Sandbox Code Playgroud)

加载该属性的类如下:

import io.quarkus.arc.config.ConfigProperties;

@ConfigProperties(prefix="sms.gateway")
public class SmsGatewayConfig {

    public Integer pinLength;

    public Integer getPinLength() {
        return pinLength;
    }

    public void setPinLength(Integer pinLength) {
        this.pinLength = pinLength;
    }
}
Run Code Online (Sandbox Code Playgroud)

这会触发错误消息:

No config value of type [java.lang.Integer] exists for: sms.gateway.pin-length
Run Code Online (Sandbox Code Playgroud)

如果我将配置文件中的 pinLength 更改为 pin-length,则相同的代码可以工作。另外,如果我将此代码更改为以下内容,它也可以正常工作:

import javax.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.config.inject.ConfigProperty;

@ApplicationScoped
public class SmsGatewayConfig {

    @ConfigProperty(name="sms.gateway.pinLength")
    public Integer pinLength;

    public Integer getPinLength() {
        return pinLength;
    }

    public void setPinLength(Integer pinLength) {
        this.pinLength = pinLength;
    }
} …
Run Code Online (Sandbox Code Playgroud)

quarkus

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

如果没有@DirtiesContext,如何在 Quarkus 中实现集成测试?

在 Spring Boot 中,我使用 @DirtiesContext 确保在每个测试用例之前清除数据库。

\n

AFAIK Quarkus 没有 @DirtiesContext 注释。相反,建议使用@TestTransaction。这样,测试用例所做的更改将在测试用例结束时回滚。这对于单元测试来说效果很好。但是,我正在努力了解如何将其用于集成测试。

\n

我的集成测试使用放心来对控制器进行休息调用。一方面,我不认为在控制器中使用 @TestTransaction 是个好主意。即使我这样做了,当其余调用返回时,数据也会被擦除。如果我在控制器中使用@Transaction,我将无法擦除下一个测试用例的数据库。

\n

所以,我的问题是你们如何解决这个问题?在进行集成测试时,如何确保有一个干净的上下文。

\n

spring spring-boot quarkus quarkus-panache

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

标签 统计

quarkus ×2

okd ×1

quarkus-panache ×1

spring ×1

spring-boot ×1