我正在使用Spring Boot Data,QueryDSL和Swagger。我已经定义了端点:
@GetMapping
public ResponseEntity<?> listOfThings(
@PageableDefault(size = 20, sort = "uID", direction = Sort.Direction.DESC) final Pageable pageable,
@QuerydslPredicate(root = Thing.class) final Predicate predicate)
Run Code Online (Sandbox Code Playgroud)
但是Swagger仅定义变量:页面,大小,排序-似乎没有解析Entity将所有字段显示为可过滤的。
我有这样的存储库:
@Repository
public interface ThingRepository
extends JpaSpecificationExecutor<Thing>, CrudRepository<Thing, String>, PagingAndSortingRepository<Thing, String>,
QuerydslPredicateExecutor<Thing>, QuerydslBinderCustomizer<QThing>
{
@Override
default void customize(final QuerydslBindings bindings, final QThing thing)
{
bindings.bind(thing.status).first((status, value) -> status.eq(value));
bindings.bind(thing.recipient).first(StringExpression::containsIgnoreCase);
bindings.bind(String.class).first((StringPath path, String value) -> path.containsIgnoreCase(value));
}
Run Code Online (Sandbox Code Playgroud)
}
我希望Swagger将所有String字段显示为过滤器,尤其是严格定义的状态和收件人。
我有运行正常的 Spring Boot 应用程序。现在我想添加点播功能以从光盘上的文件导入一些数据(它将被使用一次,永远不会再使用)。我已经准备好使用数据库连接、DTO 对象等,还有导入数据的方法。我想启动我的应用程序,例如使用命令行开关(例如 -file path/to/file)。它应该启动一个应用程序,执行我的导入方法,然后关闭。最好不要启动嵌入式Tomcat。
我正在考虑使用 @SpringBootApplication 注释的单独主类,并考虑使用 -classpath 运行,但我不知道这是个好主意。
现在我认为最好做一个小的分离项目,但也许有一个很好的功能,它允许我运行我的应用程序一次并执行导入方法。
GraphQL 和 Java (Spring) 一团糟。有多个项目,多个示例,但完全不一致。
我理解 Spring Boot 应该提供的是 OOTB 工作解决方案,并且(在某种程度上)它是这样工作的。为您提供此类体验的项目位于 Github https://github.com/graphql-java-kickstart 上。特别是https://github.com/graphql-java-kickstart/graphql-spring-boot让你可以创建模式,制作解析器,其他一切都是自动完成的。
问题是当您尝试用自定义 datafetcher 替换解析器(这看起来非常简单的 datafetcher)时。据我所知,不可能制作异步解析器或批量解析器 - 您必须制作 datafetcher。
要制作自定义数据提取器,需要进行自定义接线等,替换 spring-boot 解决方案,或以某种方式使用它(如何?)。没有一点是正确的,如何正确地做到这一点。我什至发现 BatchedDataFetcher 在它们获得良好的 Spring Boot 支持/示例之前已被弃用(!)(请参阅:GraphQL Java:使用 @Batched DataFetcher)
正因为如此,我什至不知道去哪里寻找解决方案。我希望看到的是有一个例子,它有: