您好我正在尝试重写我的旧代码以使用Spring Boot.我有一个听众public class ExecutorListener implements ServletContextListener.
如何为Spring Boot注册这个监听器?我试过了:
@SpringBootApplication
@ComponentScan
public class Application extends SpringBootServletInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
servletContext.addListener(new ExecutorListener());
}
}
Run Code Online (Sandbox Code Playgroud)
但是contextInitialized没有调用该方法.
在 keycloak Web 控制台中,可以使用
https://server.url/auth/realms/master/login-actions/reset-credentials等 url 重置密码。但用户总是需要填写电子邮件。当我从另一个应用程序重定向到此页面时,我已经知道该电子邮件,因此我想预先填写它。这有可能吗?我尝试添加参数?username=some@email.com,但不起作用,用户名/电子邮件字段仍然为空。
我有休息服务,它接受文件/内容和元数据/json 含义的多部分数据。当我用curl 测试它时,一切都很完美:
curl -X POST http://localhost:8080/upload/multi -F "file=@/tmp/1.csv" -F "meta-data={\"key\":\"test\"};type=application/json"
但现在测试人员需要在soapui 中测试它,但我无法让它工作。附加文件没有问题。问题是元数据部分似乎是作为发送的,"Content-Type: text/plain; charset=us-ascii"但我需要它作为 application/json 发送。有办法如何设置吗?或者有人有工作解决方案如何从 SoapUI 中发送内容+元数据?
@Bean
public SpringLiquibase liquibase() {
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setDataSource(vsDataSource());
liquibase.setChangeLog("classpath:liquibase/avt_changelog_master.xml");
return liquibase;
}
Run Code Online (Sandbox Code Playgroud)
这就是我通过 Spring Boot 应用程序初始化 liquibase 的方式。
我检查了数据库更改日志表,可以发现该更改集条目在那里并且已成功执行。
为什么 liquibase 不跳过该变更集并执行新的唯一变更集 ID。
我想知道是否有简单的方法(或至少计划添加该功能)如何在将规范传递给JpaSpecificationExecutor .findAll(Specification spec, Pageable pageable ) 时返回没有计数查询的Slice
所以我想做这样的事情:
Slice<MessageViewEntity> messageViewEntities =
messageViewRepository.findAll(
messageViewRepository.withSearchSpecifications(language, categoryId, messageKey, longText),
new PageRequest(page, size)
);
Run Code Online (Sandbox Code Playgroud)
不会执行 count 查询的地方。
我发现这个问题已经有将近 2 年的历史了,但在当前版本 10.1.2 中,我没有看到如何执行此操作的方法/方式。
谢谢
有可能以某种方式使用RewriteValve自定义嵌入式tomcat 吗?正如我在api中看到的那样,目前只有addContextValves和addEngineValves的方法,但是在文档中作为尖头tomcat,RewriteValve应该放在Host或webapp的context.xml中.我不明白是否addContextValves可以为此工作.
谢谢
我想在当前项目中使用 Liquibase 的两种配置。我想用于 DDL 更改的默认配置和用于自定义插入的第二个配置,其中更改日志将位于另一个位置。
如果我配置SpringLiquibase了默认的自动配置,由于类中的@ConditionalOnClass(SpringLiquibase.class)注释将被跳过LiquibaseAutoConfiguration。如何使用默认自动配置 + 我的自定义?我可以以某种方式覆盖 @ConditionalOnClass 注释吗?或者也许有什么方法可以告诉 Liquibase 我在应用程序之外还有另一个更改日志,并且只有在它存在时才运行它?
谢谢
编辑:
这可能是我的问题的解决方案,但是我在 liquibase 中加载外部文件(类路径之外的文件)时遇到问题。
@Configuration
@EnableConfigurationProperties(LiquibaseProperties.class)
public class LiquibaseConfiguration {
@Bean
SpringLiquibase liquibase(DataSource dataSource, LiquibaseProperties properties) {
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setChangeLog(properties.getChangeLog());
liquibase.setContexts(properties.getContexts());
liquibase.setDataSource(dataSource);
liquibase.setDefaultSchema(properties.getDefaultSchema());
liquibase.setDropFirst(properties.isDropFirst());
liquibase.setShouldRun(properties.isEnabled());
liquibase.setLabels(properties.getLabels());
liquibase.setChangeLogParameters(properties.getParameters());
liquibase.setRollbackFile(properties.getRollbackFile());
return liquibase;
}
@Bean
SpringLiquibase commandInitializerLiquibase(DataSource dataSource,
@Value("${docu.system.initializer.command.liquibase.changeLog}") String changeLogPath,
@Value("${docu.system.initializer.command.liquibase.contexts}") String contexts) {
File changeLog = new File(changeLogPath);
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setDataSource(dataSource);
liquibase.setContexts(contexts);
liquibase.setIgnoreClasspathPrefix(true);
liquibase.setChangeLog(changeLog.getAbsolutePath());
liquibase.setShouldRun(changeLog.exists());
//liquibase.setResourceLoader(liquibaseResourceLoader()); …Run Code Online (Sandbox Code Playgroud) 我有以下要求.
这是我目前的代码:
public CompletableFuture<ObjectId> createDeliveryNoteDocument(String productId, List<String> releaseNotesIds) {
CompletableFuture<ObjectId> deliveryNoteFuture =
CompletableFuture
.supplyAsync(() -> sequenceServiceFeignClient.getNextValueForSequenceNameNoResponseEntity(DocumentType.DELIVERYNOTE.toString()))
.whenComplete((result, error) -> {
if (error != null)
logger.error("Unable to get next sequence number for DELIVERYNOTE sequence", error);
})
.thenCompose(seqNumber -> {
Set<ObjectAttribute> objectAttributes = new HashSet<>();
objectAttributes.add(new ObjectAttribute(Constants.Document.DOCUMENT_TYPE, DocumentType.DELIVERYNOTE.toString()));
objectAttributes.add(new ObjectAttribute(Constants.Document.DOCUMENT_NO, seqNumber));
objectAttributes.add(new ObjectAttribute(Constants.Document.PRODUCT_ID, productId));
return objectCommandService.createCustomObject(new ObjectTypeTableName(Constants.ObjectTables.DOCUMENT), objectAttributes);
});
CompletableFuture<Void> releaseNotesFuture =
deliveryNoteFuture
.thenComposeAsync(deliveryNoteId -> joinReleaseNotesWithDeliveryNote(deliveryNoteId, releaseNotesIds));
CompletableFuture<Void> parcelsFuture =
deliveryNoteFuture
.thenComposeAsync(deliveryNoteId -> changeParcelsStatusForReleaseNotes(releaseNotesIds));
return deliveryNoteFuture;
}
Run Code Online (Sandbox Code Playgroud)
我怎么能等待 …
我正在玩Couchbase和Spring数据Couchbase。为此,我已经安装了带有版本号5.5.1 build 3511并启用了测试桶的ouchbase 。我已经beer-sample用密码创建了用户,beer-sample并向他添加了bucket的所有权限beer-sample。
然后,我创建了带有示例配置的示例应用程序。当我启动该应用程序并查询存储桶中的现有啤酒时,出现异常:
com.couchbase.client.java.error.ViewDoesNotExistException: View beer/all does not exist.
at com.couchbase.client.java.view.ViewQueryResponseMapper$BuildViewResult.call(ViewQueryResponseMapper.java:211)
at com.couchbase.client.java.view.ViewQueryResponseMapper$BuildViewResult.call(ViewQueryResponseMapper.java:185)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.producers.SingleProducer.request(SingleProducer.java:65)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.internal.operators.OperatorSingle$ParentSubscriber.onCompleted(OperatorSingle.java:113)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.checkTerminated(OperatorObserveOn.java:281)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:216)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.java.document.json.JsonObject.class
at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:118)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73)
... 16 more
Run Code Online (Sandbox Code Playgroud)
我猜应该使用我的配置自动创建索引,但是也许我错了。