小编LeO*_*LeO的帖子

使用 log4j2.xml 进行 Elasticsearch 配置

我正在初始化 elasticsearch 客户端,new PreBuiltTransportClient(Settings.EMPTY);并且我有以下配置:

pom.xml

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.8.1</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.25</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.8.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

因为 log4j2 采用 xml 文件 ==> log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">

    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
        </Console>

        <RollingFile name="RollingFile" filename="log/rolling.log"
            filepattern="${logPath}/%d{YYYYMMddHHmmss}-rolling.log">
            <PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
            <Policies>
                <SizeBasedTriggeringPolicy size="100 MB" />
            </Policies>
            <DefaultRolloverStrategy max="20" />
        </RollingFile>

    </Appenders>
    <Loggers>
        <Root level="info">
            <AppenderRef ref="Console" />
            <AppenderRef …
Run Code Online (Sandbox Code Playgroud)

java elasticsearch log4j2

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

如何在SpringMVC(5.x)项目中启用ehCache(3.x)

在我们的项目中,我们使用ehcache2.x,现在我们想迁移到3.x,但是以某种方式我失败了。在2.x中,我们有配置ehcache.xml。我读到的是,使用3.x时也需要更改内容。

但是首先,我不知道如何单独连接缓存。我有

@EnableCaching
@Configuration
public class CacheConf {
  @Bean
  public CacheManager cacheManager() {
    final CacheManagerBuilder<org.ehcache.CacheManager> ret = CacheManagerBuilder.newCacheManagerBuilder();
    ret.withCache("properties", getPropCache());
    ret.withCache("propertyTypes", getPropCache());
    return (CacheManager) ret.build(true);
  }
....
Run Code Online (Sandbox Code Playgroud)

但是,我得到的这种配置java.lang.ClassCastException: org.ehcache.core.EhcacheManager cannot be cast to org.springframework.cache.CacheManager意味着我无法ehcache正确设置。

注意:在2.x版本中,我们配置了不同类型的缓存,或多或少是由于有效期-以及其他对象类型存储在其中。

提示使其运行,因为在Spring 5和ehcache3.x中找不到有效的示例?最好是没有xml的配置!

java spring ehcache

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

如何在 mat-tab-group 中为 Angular 更改过渡效果?

Angular已经包含mat-tab-group了每个mat-tab动画效果。给定的动画效果很烦人,因此我想使用不同的动画效果。我已经一个fadeinfadeout从别人别人

export const fadeAnimation = trigger('fadeAnimation', [
  // The '* => *' will trigger the animation to change between any two states
  transition('* => *', [
    // The query function has three params.
    // First is the event, so this will apply on entering or when the element is added to the DOM.
    // Second is a list of styles or animations to apply.
    // Third we add a config …
Run Code Online (Sandbox Code Playgroud)

angular-material angular

3
推荐指数
2
解决办法
3681
查看次数

Java 8:方法作为Lambda引用的参数

我已经扫描了几个链接,但没有找到Java 8 Lambda表达式的简单解决方案.我发现最有用的提示是在Java 8 Lambdas上,但并没有真正满足我的兴趣.

我想在我的代码中实现reoccuring模式:

List<?> content=retrieveContent(strFilter);
if (!content.isEmpty())
    setField1(content.get(0));
Run Code Online (Sandbox Code Playgroud)

我想简单一点

retrieveContent(strFilter, this::setField1)但不知怎的,我没有正确的语法 - 特别是对于方法.我可以做一个字符串,如果通过方法调用,但比它容易出现错别字......还有其他想法吗?

java lambda

2
推荐指数
1
解决办法
426
查看次数

材料表 - 以编程方式触发过滤器

根据这个示例,我知道我可以编写自己的this.dataSource.filterPredicate. 只要我搜索字符串,这就可以正常工作。我想根据使用的state(= myFilterState) 进行额外过滤。

我尝试使用谓词

this.dataSource.filterPredicate = 
    (data: MyElement, filter: string) => data.myType.useState === this.myFilterState;
Run Code Online (Sandbox Code Playgroud)

我面临的问题是,当我更改this.myFilterState过滤器时,直到我更改filter. 只要filter保持为空,就filterPredicate不会触发。

有没有办法手动触发它 - 尽管 的值filter

angular-material angular-material-table

2
推荐指数
1
解决办法
857
查看次数

Haskell:将Double转换为Int

我想从固定基数计算"我必须使用的数字的哪个幂",例如2.

我想找到一个数字的下一个(整数)幂,例如2 ^ 3 = 8 ==> get2Power 8 ==> 3.

这很简单,但 get2Power 10 ==> 4 由于2^3=8下限和2^4=16上限我想返回上限,4.

通过简单的数学运算,我知道我可以用一些对数函数来计算功率,即log(x) / log(2)得到一个Double.但我希望有下一个Integer.

我的方法看起来像

get2Power :: Integer -> Integer
get2Power x 
  | x <= 0 = -1
  | otherwise = round (log(x) / log (2))     
Run Code Online (Sandbox Code Playgroud)

失败的原因是类型之间缺少一些转换.错误消息无助于了解我所缺少的内容.

有人可以帮我解决如何将Double结果转换为Integer/int的问题吗?

haskell type-conversion

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

Haskell:整数的列表组合

我有一个给定的列表,例如[2, 3, 5, 587],我想要一个完整的组合列表.所以想要类似的东西[2, 2*3,2*5, 2*587, 3, 3*5, 3*587, 5, 5*587, 587].由于我在初学者级别与Haskell,我很好奇列表操作将如何.

另外,我很好奇如果基本列表的计算可能很昂贵,这将如何影响函数的成本?(如果我认为列表有限制值,即<20)

Rem:列表的顺序可以在之后完成,但我真的不知道如果在函数内或之后更便宜.

haskell

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

用于 Mat-button-toggle 的 Angular 6(和 7)主题

我找到了如何自定义材质切换按钮的精彩链接。我成功设置background-colorfont-weight我想的方式

@import '~@angular/material/theming';

@include mat-core();

$app-primary: mat-palette($mat-indigo);
$app-accent:  mat-palette($mat-pink, A200, A100, A400);

$app-theme: mat-light-theme($app-primary, $app-accent);

@mixin mix-app-theme($app-theme) {
  $primary: map-get($app-theme, primary);
  $accent: map-get($app-theme, accent);

.mat-button-toggle-checked {
    background-color: mat-color($primary);
    font-weight: bold;
    color:mat-color($primary); // <=== does not work!!!
  }
}

// Include the mixin
@include mix-app-theme($app-theme);
Run Code Online (Sandbox Code Playgroud)

但不知何故,字体本身保持黑色 - 这不是使用color="primary".

知道如何包括fore-color- 正确吗?

angular-material angular angular-material-6

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

Angular 14:带有布尔值和默认值的类型化 FormControls

我尝试以下方法

    new FormControl<boolean | undefined>({ value: true }, Validators.required),
Run Code Online (Sandbox Code Playgroud)

overloads并得到 no for存在的错误boolean。使用

    new FormControl<string | null>({ value: null, disabled: false }));
Run Code Online (Sandbox Code Playgroud)

有效 ==> 那么,Angular 14 中 Typed FormControls 的正确语法是什么boolean

angular angular-forms angular14

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