小编Cha*_*ata的帖子

颤动:设置AppBar的高度

我怎样才能简单地设置AppBarFlutter 的高度?

酒吧的标题应该垂直居中(在那里AppBar).

dart material-design flutter

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

时间戳相对于当前时间的部分索引

我有一个查询,通过比较五个月前的插入时间戳来过滤行。

该字段不会更新,如果有帮助的话我们可能会认为它是不可变的。

CREATE TABLE events (
    id serial PRIMARY KEY,
    inserted_at timestamp without time zone DEFAULT now() NOT NULL
);

SELECT *
FROM events e
WHERE e.inserted_at >= (now() - '5 minutes'::interval);
Run Code Online (Sandbox Code Playgroud)

EXPLAIN ANALYZE VERBOSE

Seq Scan on public.events e  (cost=0.00..459.00 rows=57 width=12) (actual time=0.738..33.127 rows=56 loops=1)
    Output: id, inserted_at
    Filter: (e.inserted_at >= (now() - '5 minutes'::interval))
    Rows Removed by Filter: 19944
Planning time: 0.156 ms
Execution time: 33.180 ms
Run Code Online (Sandbox Code Playgroud)

看来 PostgreSQL 在现场执行序列扫描,这会增加成本。

我是否有机会创建 B 树部分索引或其他任何内容来优化该查询?

postgresql indexing timestamp query-optimization partial-index

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

从bean工厂访问injectee组件

假设我们有一个原型范围的bean.

public class FooConfiguration {
  @Bean
  @Scope("prototype")
  public Foo foo(@Autowired Bar bar) {
    return new Foo(bar);
  }
}
Run Code Online (Sandbox Code Playgroud)

我们将这个bean注入一个类,TheDependent.

@Component
public class TheDependent {
  @Autowired
  private Foo foo;
}
Run Code Online (Sandbox Code Playgroud)

但还有另外一个.

@Component
public class AnotherOne {
  @Autowired
  private Foo foo;
}
Run Code Online (Sandbox Code Playgroud)

在每个中@Autowired,Foo都创建了一个新的gets 实例,因为它是用它注释的@Scope("prototype").

我想从工厂方法访问'dependent'类FooConfiguration#foo(Bar).可能吗?Spring可以为工厂方法的参数注入某种上下文对象,提供有关注入点的信息吗?

java spring dependency-injection javabeans

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

Spring Boot中的多态配置属性

我想使用Spring的@ConfigurationProperties注释在Spring上使用多态配置属性.

假设我们有以下POJO类.

public class Base {
  private String sharedProperty;

  public String getSharedProperty() {
    return sharedProperty;
  }

  public String setSharedProperty(String sharedProperty) {
    this.sharedProperty = sharedProperty;
  }
}

public class Foo extends Base {
  private String fooProperty;

  public String getFooProperty() {
    return fooProperty;
  }

  public String setFooProperty(String sharedProperty) {
    this. fooProperty = fooProperty;
  }
}

public class Bar extends Base {
  private String barProperty;

  public String getSharedProperty() {
    return sharedProperty;
  }

  public String setBarProperty(String barProperty) {
    this.barProperty = barProperty;
  } …
Run Code Online (Sandbox Code Playgroud)

java spring yaml spring-boot configurationproperties

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

为什么不是每次使用Basic Auth代替JWT?

我正在Hapi 中编写RESTFUL API,我无法弄清楚API身份验证方法.

假设我们在HTTP/1.1中使用SSL/TLS,为什么我们需要JSON Web Token(JWT),我们已经有了HTTP基本身份验证.我们可以使用HTTP Basic Auth保护每个端点,因此我们甚至不需要像这样的登录路由'/login'.

那么,OAuth和JWT的认证方案有什么意义呢?

谢谢.

authentication rest hapijs

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