我正在努力解决返回 HashMap<String, List> 的 API 的 API 规范。API 本身完全按照我想要的方式工作,但我希望 OpenAPI 正确指定返回类型。我一直在谷歌搜索并找到 SchemaType.ARRAY,这使它更好,但现在当我在 Swagger 中查看时,它被指定为一个数组,它更接近我想要的 HashMap,而不是我更改 SchemaType 之前的单个对象。
'''
@GET
@Path("/")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
@Operation(
summary = "All grunddata forapplikationen")
@APIResponse( responseCode="200",
description="All grunddata in the system",
content= @Content(schema = @Schema(type = SchemaType.ARRAY, implementation = Grunddata.class))
)
Run Code Online (Sandbox Code Playgroud)
'''
我在搜索时发现的一个有希望的解决方案是创建一个扩展 HashMap<String, List> 的 clss 并使用它来实现,但这只会导致 API 似乎只重新运行一个简单的 String。
虽然使用依赖插件的公认答案是当时最好的解决方案,但@ltlBeBoy 的答案利用了自添加到自由行家插件以来的“copyDependencies”支持。使用 'copyDependencies' 通常是一个更好的解决方案,因为它被集成到“开发模式”循环中并且不那么冗长(以支持比依赖插件更少的选项为代价)。
我需要复制derby.jar到 Open Liberty 共享目录中
${project.build.directory}/liberty/wlp/usr/shared/resources/。我在 pom.xml 文件中有以下设置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-derby-dependency</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>derby</includeArtifactIds>
<outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
以及配置开放自由的部分
<plugin>
<groupId>net.wasdev.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>${openliberty.maven.version}</version>
<executions>
<execution>
<id>package-server</id>
<phase>package</phase>
<goals>
<goal>create-server</goal>
<goal>install-apps</goal>
<goal>package-server</goal>
</goals>
<configuration>
<outputDirectory>target/wlp-package</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>${openliberty.version}</version>
<type>zip</type>
</assemblyArtifact>
<configFile>src/main/liberty/config/server.xml</configFile>
<appArchive>${project.build.directory}/${final.name}.war</appArchive>
<packageFile>${project.build.directory}/${final.name}.jar</packageFile>
<include>runnable</include>
<serverName>${final.name}</serverName>
<installAppPackages>project</installAppPackages>
<configDirectory>${project.basedir}/src/main/liberty/server</configDirectory>
<bootstrapProperties>
<project.name>${final.name}</project.name>
<jwt.issuer>https://server.example.com</jwt.issuer>
</bootstrapProperties>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
有了这个设置,我必须执行mvn …
我在普罗米修斯中有以下标签,如何在模板化“query”之类的内容时创建通配符查询:“label_values(application_*Count_Total,xyx)”。这些值是从 Eclipse Microprofile REST-API 生成的
application_getEnvVariablesCount_total
application_getFEPmemberCount_total
application_getLOBDetailsCount_total
application_getPropertiesCount_total
Run Code Online (Sandbox Code Playgroud)
{
"allValue": null,
"current": {
"isNone": true,
"selected": false,
"text": "None",
"value": ""
},
"datasource": "bcnc-prometheus",
"definition": "microprofile1",
"hide": 0,
"includeAll": false,
"label": null,
"multi": false,
"name": "newtest",
"options": [
{
"isNone": true,
"selected": true,
"text": "None",
"value": ""
}
],
"query": "microprofile1",
"refresh": 0,
"regex": "{__name__=~\"application_.*Count_total\"}",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
},
Run Code Online (Sandbox Code Playgroud) 在使用 Kotlin 的 Microprofile / Quarkus 项目中,有一个数据类,其变量类型为 Instant。
@Schema(name = "Vehicle", description = "POJO that represents a vehicle at a specific time.")
data class VehicleDTO(
var time: Instant = Instant.EPOCH
)
Run Code Online (Sandbox Code Playgroud)
问题是生成的openapi schema并不能代表Instant的值是如何实际传输的。
架构如下所示,而它只是简单地表示为这样的字符串: 2015-06-02T21:34:33.616Z.
Instant:
type: object
properties:
nanos:
format: int32
type: integer
seconds:
format: int64
type: integer
epochSecond:
format: int64
type: integer
nano:
format: int32
type: integer
Run Code Online (Sandbox Code Playgroud)
我已经尝试注释数据类以使用实现字符串和类型字符串,但它没有改变任何东西。
@Schema(name = "Vehicle", description = "POJO that represents a vehicle at a specific time.")
data class VehicleDTO(
@Schema(implementation = String::class, …Run Code Online (Sandbox Code Playgroud) 我知道你可以实施 ObjectMapperCustomizer为 Quarkus REST 服务配置映射器。但是,Quarkus REST Client 的文档中并不清楚它是否会使用相同的(全局?)映射器。当外部服务与您自己的服务具有不同的 JSON 命名约定时,您如何处理这种情况?我找不到为 REST 客户端配置 ObjectMapper 的方法。我假设您可能可以使用 Jackson 注释来解决这个问题,但我正在寻找一种方法来仅通过配置 ObjectMapper 来实现。
所以,基本上,问题是:如何为一个特定的REST 客户端配置一个单独的ObjectMapper ?
当使用 Quarkus microprofile 作为 REST 客户端时,如何配置底层 HttpClient?比如重试次数、每个主机的连接池大小等等?另外是否可以以某种方式强制客户端重新启动(因此连接池将重新启动)?
我正在使用 Helidon MP 开发微服务应用程序。到目前为止我的经历非常棒。但我最终寻找 Helidon MP 的启动/关闭挂钩。我试图通过搜索和 Helidon Javadoc 来查找。但我找不到任何有用的东西。
Helidon MP / Microprofile 是否提供此类功能?
在 Java EE 中,我使用 EJB 计时器服务来安排任务:
@Stateless
public class TestSchedule {
@Schedule(second = "*/30", minute = "*", hour = "*")
public void processFiles() {
}
}
Run Code Online (Sandbox Code Playgroud)
由于 Eclipse Micro Profile 不支持这种方法...实现这一点的常用方法是怎样的?
websphere-liberty payara payara-micro microprofile jakarta-ee
带有JSF的Quarkus JVM模式
我有一个使用JSF和JEE(CDI / EJB)构建的基于thorntail 2.4的Web应用程序。
对于我上面的技术堆栈,如果我仅使用JVM模式而不是纯模式,是否可以使用运行时打包应用程序?
我知道EJB规范不是用quarkus实现的,我可以将EJB重写为CDI + JTA服务,但是我想知道是否可以在quarkus中使用JSF。
我从一个普通的 Java EE 应用程序转移到 quarkus.io。在 Java EE 中,我有一个属性文件,
version=${project.version}并在 JAX RS 端点中读取此文件。这非常有效。
@GET
public Response getVersion() throws IOException {
InputStream in = getClass().getClassLoader().getResourceAsStream("buildInfo.properties");
if (in == null) {
return Response.noContent().build();
}
Properties props = new Properties();
props.load(in);
JsonObjectBuilder propertiesBuilder = Json.createObjectBuilder();
props.forEach((key, value) -> propertiesBuilder.add(key.toString(), value.toString()));
return Response.ok(propertiesBuilder.build()).build();
}
Run Code Online (Sandbox Code Playgroud)
现在我在用quarkus和MicroProfile,不知道有没有更好的方法。
我使用 MicroProfile 的 ConfigProperty 设置进行了尝试。
@ConfigProperty(name = "version")
public String version;
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
Property project.version not found.
这是我的 pom 的构建部分。
<build>
<finalName>quarkus</finalName>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>1.0.0.CR2</version>
<executions>
<execution> …Run Code Online (Sandbox Code Playgroud) 我正在调用一个端点,其中我需要的信息在响应标头中返回(https://keycloak.discourse.group/t/rest-api-create-user-no-user-identifier-in-response/1964/ 4 ). 如果我使用 Quarkus REST 客户端 ( https://quarkus.io/guides/rest-client ),如何检索此信息?
我知道我可以使用@ClientHeaderParamor@HeaderParam将标头放入响应中。我想要的恰恰相反。
microprofile ×11
quarkus ×6
java ×2
openapi ×2
cdi ×1
derby ×1
grafana ×1
helidon ×1
jackson ×1
jakarta-ee ×1
jsf ×1
kotlin ×1
maven ×1
open-liberty ×1
payara ×1
payara-micro ×1
prometheus ×1
thorntail ×1