小编Chr*_*one的帖子

更改 Spring openapi-generator-maven-plugin 生成的接口的返回类型

我已成功从 .yaml open-api 描述符文件生成接口,但是,如问题标题所示,我希望将这些接口的响应类型从 ResponseEntity 更改为我自己的类型。基本上而不是具有此签名的接口:

 ResponseEntity<Void> clearCache();
Run Code Online (Sandbox Code Playgroud)

对于基本上以这种方式实现的方法:

public void clearCache(){ //do something}
Run Code Online (Sandbox Code Playgroud)

我希望生成的界面就像

void clearCache();
Run Code Online (Sandbox Code Playgroud)

对于我自己定义的类来说也是如此,而不是ResponseEntity<MyBook> getBook(String ISBN);我希望它只用作MyBook返回类型,所以它应该看起来像MyBook getBook(String ISBN); 我用于 openapi-generator 插件的当前设置是

        <plugin>
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <version>4.3.0</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <inputSpec>my-own-service-be/src/main/resources/api-docs.yaml</inputSpec>
                        <generatorName>spring</generatorName>
                        <additionalProperties>
                             <additionalProperty>skipDefaultInterface=true</additionalProperty>
                            <additionalProperty>interfaceOnly=true</additionalProperty>
                        </additionalProperties>
                        <generateApis>true</generateApis>
                        <apiPackage>controller</apiPackage>
                        <supportingFilesToGenerate>false</supportingFilesToGenerate>
                        <modelPackage>dto</modelPackage>
                        <generateModelTests>false</generateModelTests>
                        <generateApiTests>false</generateApiTests>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot openapi openapi-generator

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

如何为整个 docker-compose 堆栈设置内存限制?

除了为 docker-compose 内的每个服务(容器)设置限制之外,我很想知道是否有任何方法可以简单地限制 docker-compose 堆栈可以访问的内存,类似于每个容器的解决方案,但概括为所有堆栈。

linux docker docker-compose docker-container

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

JPA 查询使用 Between 和 Instant 不起作用

我正在尝试进行查询以检索在两个日期之间创建的一些数据(表示为即时)。

下面是我正在使用的实体的摘录:

@Entity
public class HistoricalData {
@Id
@GeneratedValue
private Long id;

@Column
private String name;

@CreationTimestamp
private Instant timestamp;

@Column
private Double price;

}
Run Code Online (Sandbox Code Playgroud)

我编写的查询是为了检索两个 Instant 之间的数据;

@Query("select h from HistoricalData h where h.timestamp between :timestampStart and :timestampEnd and upper(name) = upper(:name)")
List<HistoricalData> findHistoricalDataBetween(@NonNull Instant timestampStart, @NonNull Instant timestampEnd, @NonNull String name);
Run Code Online (Sandbox Code Playgroud)

它产生这个 SQL 查询:

select historical0_.id as id1_5_, historical0_.price as price2_5_, historical0_.timestamp as timestam3_5_ from historical_data historical0_ where (historical0_.timestamp between ? and ?) and upper(historical0_.name)=upper(?)
Run Code Online (Sandbox Code Playgroud)

我还编写了“hibernate JPA”查询只是为了尝试但没有成功:

List<HistoricalData> …
Run Code Online (Sandbox Code Playgroud)

mysql jpql mariadb spring-data-jpa spring-boot

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