小编Hoo*_*Yao的帖子

将Spring Data的ReactiveCrudRepository应用于Redis

我正在玩Spring Boot 2 webflux.我正在尝试使用它ReactiveSortingRepository来简化redis操作.

public interface DataProfileRepository extends ReactiveSortingRepository<DataProfileDTO, String> {
}
Run Code Online (Sandbox Code Playgroud)

只需使用此界面即可

Mono<DataProfileDTO> tmp = this.dataProfileRepository.findById(id);
Run Code Online (Sandbox Code Playgroud)

例外:

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.tradeshift.dgps.dto.DataProfileDTO] to type [reactor.core.publisher.Mono<?>]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:174) ~[spring-core-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.data.repository.util.ReactiveWrapperConverters.toWrapper(ReactiveWrapperConverters.java:197) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.repository.core.support.QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java:104) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:587) ~[spring-data-commons-2.0.2.RELEASE.jar:2.0.2.RELEASE]
Run Code Online (Sandbox Code Playgroud)

被扔了.

此存储库的行为与reactor不匹配,我可以在调试模式中看到,实际DataProfileDTO是从redis获取的.尝试时失败了:

GENERIC_CONVERSION_SERVICE.convert(reactiveObject, targetWrapperType);
Run Code Online (Sandbox Code Playgroud)

ReactiveWrapperConverters.toWrapper

我去谷歌搜索,似乎Spring Data Redis 2.0没有提到反应式存储库支持.我想知道我的代码或Spring Data Redis 2.0中是否有任何错误,我还不支持ReactiveCrudRepository.

spring-data-redis reactive

14
推荐指数
1
解决办法
1621
查看次数

将WordPress安装在自己的目录中,但固定链接失败

我在位于的EC2上安装了WordPress /var/www/html/wordpress.我按照WordPress指南将index.php和.htaccess复制到root /var/www/html,并修改了index.php并在管理面板中进行了设置.如果我只坚持默认链接,它会很好用,例如:http://www.cubcanfly.com/?p=5,但是其他永久链接选项失败,实际上所有固定链接选项.

我的.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

/etc/httpd/conf/httpd.conf中

LoadModule rewrite_module modules/mod_rewrite.so
Run Code Online (Sandbox Code Playgroud)

没有评论.

提前致谢

wordpress .htaccess rewrite permalinks amazon-ec2

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

.net 核心 AsyncLocal 失去价值

我使用与HttpContextAccessor类似的模式

简化版如下,Console.WriteLine(SimpleStringHolder.StringValue)不应该是null。

public class SimpleStringHolder
{
    private static readonly AsyncLocal<ValueHolder> CurrentHolder = new AsyncLocal<ValueHolder>();

    public static string StringValue
    {
        get => CurrentHolder.Value?.StringValue;

        set
        {
            var holder = CurrentHolder.Value;
            if (holder != null)
            {
                holder.StringValue = null;
            }

            if (value != null)
            {
                CurrentHolder.Value = new ValueHolder() { StringValue = value };
            }
        }
    }

    private class ValueHolder
    {
        public string StringValue;
    }
}
Run Code Online (Sandbox Code Playgroud)
class Program
{
    private static readonly AsyncLocal<string> currentValue = new AsyncLocal<string>();

    public static …
Run Code Online (Sandbox Code Playgroud)

c# async-await

3
推荐指数
1
解决办法
373
查看次数