我搜索了一个答案但找不到任何答案,所以我在这里问,我有一个更新上下文的消费者,另一个应该显示上下文的消费者。我正在使用与打字稿(16.3)的反应
上下文(AppContext.tsx):
export interface AppContext {
jsonTransactions: WithdrawTransactionsElement | null;
setJsonTran(jsonTransactions: WithdrawTransactionsElement | null): void;
}
export const appContextInitialState : AppContext = {
jsonTransactions: null,
setJsonTran : (data: WithdrawTransactionsElement) => {
return appContextInitialState.jsonTransactions = data;
}
};
export const AppContext = React.createContext(appContextInitialState);
Run Code Online (Sandbox Code Playgroud)
生产者(App.tsx):
interface Props {}
class App extends React.Component<Props, AppContext> {
state: AppContext = appContextInitialState;
constructor(props : Props) {
super(props);
}
render() {
return (
<AppContext.Provider value={this.state}>
<div className="App">
<header className="App-header">
<SubmitTransactionFile/>
<WithdrawTransactionsTable />
</header>
</div>
</AppContext.Provider>
);
} …
Run Code Online (Sandbox Code Playgroud) 我已经搜索了高低,但仍然无法找到这个非常烦人的问题的简单答案,
我遵循了这个很棒的指南: 带有多服务应用程序的 JWT 一切都很好,但在指南的最后,我们建议创建一个 config-service(module) ,我已经完成了。
问题是我无法覆盖 JwtConfig 类的默认配置
项目结构如下:
-config-service
| JwtConfig.java
\
| resources
\
| jwtConfig.properties
-other-service (add dependency in the pom file of the config-service)
|
someOtherclass.java (import the JwtConfig class & using @Bean to initialize )
Run Code Online (Sandbox Code Playgroud)
JwtConfig 类:
/*all the imports*/
@PropertySource(value = "classpath:jwtConfig.properties")
public class JwtConfig {
@Value("${security.jwt.uri:/auth/**}")
private String Uri;
@Value("${security.jwt.header:Authorization}")
private String header;
@Value("${security.jwt.prefix:Bearer }")
private String prefix;
@Value("${security.jwt.expiration:#{24*60*60}}")
private int expiration;
@Value("${security.jwt.secret:JwtSecretKey}")
private String secret;
//getters
Run Code Online (Sandbox Code Playgroud)
someOtherclass.java:
/*imports*/
@Configuration
@EnableWebSecurity …
Run Code Online (Sandbox Code Playgroud) maven multi-module spring-boot application.properties java-11
我在 Postgres 9.6 上执行了以下 jooq 语句:
DSLContext context = DSL.using(connection, POSTGRES_10);
testSafesFundsAllocationRecord record =
context.select()
.from(
select(
TEST_SAFES_FUNDS_ALLOCATION.LEDGER_ID,
sum(TEST_SAFES_FUNDS_ALLOCATION.AMOUNT)
.as(TEST_SAFES_FUNDS_ALLOCATION.AMOUNT))
.from(TEST_SAFES_FUNDS_ALLOCATION)
.groupBy(TEST_SAFES_FUNDS_ALLOCATION.LEDGER_ID))
.where(TEST_SAFES_FUNDS_ALLOCATION.AMOUNT.greaterOrEqual(amount))
.and(TEST_SAFES_FUNDS_ALLOCATION.LEDGER_ID.notIn(excludedLedgers))
.orderBy(TEST_SAFES_FUNDS_ALLOCATION.AMOUNT.asc())
.limit(1)
.fetchOne()
.into(TEST_SAFES_FUNDS_ALLOCATION);
Run Code Online (Sandbox Code Playgroud)
其翻译如下:
SQL [
select "alias_88420990"."ledger_id", "alias_88420990"."amount" from (
select "public"."test_safes_funds_allocation"."ledger_id",
sum("public"."test_safes_funds_allocation"."amount") as "amount" from "public"."test_safes_funds_allocation" group by "public"."test_safes_funds_allocation"."ledger_id") as "alias_88420990"
where ("public"."test_safes_funds_allocation"."amount" >= ? and 1 = 1) order by "public"."test_safes_funds_allocation"."amount" asc limit ?];
Run Code Online (Sandbox Code Playgroud)
exceptedLedgers -> 是一个空字符串数组
结果是:
org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "test_safes_funds_allocation"
Position: 334
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我查询中有什么问题吗?正如你所看到的,它是嵌套的......但我似乎无法理解这个问题。查询执行以下操作:将同一分类帐 id(分组依据)的所有金额行相加,然后从输出中返回金额大于可变金额的最小行,我们可以通过数组排除特定的行ledger_id
(在此为空)例子)。 …
我为 RSocket 消息写了一个小演示
问题是我无法访问Rsocket
端点,我从服务器收到以下异常:
客户端: 配置:
@Bean
RSocket rSocket() {
return RSocketFactory.connect()
.mimeType(MimeTypeUtils.APPLICATION_JSON_VALUE, MimeTypeUtils.APPLICATION_JSON_VALUE)
.frameDecoder(PayloadDecoder.ZERO_COPY)
.transport(TcpClientTransport.create(new InetSocketAddress(7500)))
.start()
.block();
}
@Bean
RSocketRequester requester(RSocketStrategies strategies) {
return RSocketRequester.wrap(rSocket(), MimeTypeUtils.APPLICATION_JSON, MimeTypeUtils.APPLICATION_JSON, strategies);
}
Run Code Online (Sandbox Code Playgroud)
控制器:
private final RSocketRequester requester;
@GetMapping("/greet/{name}")
public Publisher<GreetingsResponse> greet(@PathVariable String name) {
return requester
.route("hello")
.data(new GreetingsRequest(name))
.retrieveMono(GreetingsResponse.class);
}
Run Code Online (Sandbox Code Playgroud)
服务器端(使用spring Rsocket): yml:
spring:
rsocket:
server:
port: 7500
transport: tcp
main:
lazy-initialization: true
Run Code Online (Sandbox Code Playgroud)
配置:
spring:
rsocket:
server:
port: 7500
transport: tcp
main:
lazy-initialization: true
Run Code Online (Sandbox Code Playgroud)
我很确定它与新wrap
函数有关,RSocketRequester.wrap …
Java版本:11.0.13
我有一个在运行时将java文件编译成类的函数,
在 Java 8 上一切正常,在 Windows 上使用 java 11.0.13 一切正常
但在 Linux(Red Hat Enterprise Linux Server 版本 6.10)上,它失败并出现StackOverflowError
代码:
public Class<?> compile(String className, String content) {
Lookup lookup = MethodHandles.lookup();
ClassLoader cl = lookup.lookupClass().getClassLoader();
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
try {
ClassFileManager fileManager = new ClassFileManager(compiler.getStandardFileManager(null, null, null));
List<CharSequenceJavaFileObject> files = new ArrayList<>();
files.add(new CharSequenceJavaFileObject(className, content));
StringWriter out = new StringWriter();
CompilationTask task = compiler.getTask(out, fileManager, null, compilerOptions, null, files);
task.call();
if (fileManager.isEmpty())
throw new CompilationException("Compilation error: " + …
Run Code Online (Sandbox Code Playgroud) 我无法理解这个问题,我不确定我做错了什么。
我想等待 Flux 结束然后Mono
返回serverResponse
我已附上代码片段,它将doOnNext
填充categoryIdToPrintRepository
.
我已经查看了如何在通量结束后返回单声道,并发现了“then”,但在处理 onNextSite 之前仍然执行“then”方法,这会导致错误:
java.lang.IllegalArgumentException: 'producer' type is unknown to ReactiveAdapterRegistry
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
public Mono<ServerResponse> retrieveCatalog(ServerRequest ignored) {
return Mono.just("start").flatMap(id ->
Flux.fromIterable(appSettings.getSites())
.subscribeOn(ForkJoinPoolScheduler.create("SiteCatalogScheduler"))
.doOnNext(this::onNextSite)
.then(Mono.from(ServerResponse.ok().body(categoryIdToPrintRepository.getSortedTreeValues(), String.class))));
}
private void onNextSite(Integer siteId) {
IntStream.range(1, appSettings.getCatalogMaxValue()).parallel().forEach(catalogId -> {
Optional<SiteCatalogCategoryDTO> cacheData =
siteCatalogCacheUseCaseService.getSiteCatalogResponseFromCache(siteId, catalogId);
cacheData.ifPresentOrElse(siteCatalogCategoryDTO -> {/*do nothing already exist in cache*/},
() -> {
Mono<SiteCatalogCategoryDTO> catalogCategoryDTOMono = WebClient.create(getUri(siteId, catalogId))
.get().retrieve().bodyToMono(SiteCatalogCategoryDTO.class);
catalogCategoryDTOMono.subscribe(siteCatalogCategoryDTO ->
handleSiteServerResponse(siteCatalogCategoryDTO, siteId, catalogId));
});
});
}
private void handleSiteServerResponse(SiteCatalogCategoryDTO siteCatalogCategoryDTO, …
Run Code Online (Sandbox Code Playgroud) 我在以下配置中使用咖啡因:
Cache<String, String> cache = Caffeine.newBuilder()
.executor(newWorkStealingPool(15))
.scheduler(createScheduler())
.expireAfterWrite(10, TimeUnit.SECONDS)
.maximumSize(MAXIMUM_CACHE_SIZE)
.removalListener(this::onRemoval)
.build();
private Scheduler createScheduler() {
return forScheduledExecutorService(newSingleThreadScheduledExecutor());
}
Run Code Online (Sandbox Code Playgroud)
我是否正确地假设该onRemoval
方法将在 ForkJoinPool 上执行newWorkStealingPool(15)
,并且只会调用调度程序来查找需要驱逐的过期条目?
这意味着它会像这样:
newWorkStealingPool(15)
对缓存构建器中的定义中的每个被逐出的条目执行 onRemoval 吗?我没有找到解释此行为的文档,所以我在这里询问
总氮
java ×5
spring-boot ×3
java-11 ×2
java-8 ×2
netty ×2
caching ×1
javacompiler ×1
javascript ×1
jooq ×1
maven ×1
multi-module ×1
postgresql ×1
reactjs ×1
rsocket ×1
sql ×1
typescript ×1