小编Moh*_*eem的帖子

如何在未排序的只读数组中找到第K个最小整数?

这是一个标准问题,已在多个站点中多次回答,但在此版本中还有其他限制:

  1. 该数组是只读的(我们无法修改数组).
  2. 在O(1)空间中进行.

有人可以在最佳的时间复杂性中向我解释这种方法.

arrays algorithm

11
推荐指数
2
解决办法
6716
查看次数

@Transactional(readOnly = true) 未按 Spring 框架 5.2 版的预期工作

Spring Framework 5.2 版开始,每当一个方法被标记为 @Transactional(readOnly=true) 我应该期待:

  • Session.setDefaultReadOnly(true).
  • flushMode 设置为MANUAL / NEVER但不是COMMIT(根据这篇文章和这个答案)。

但是,当我尝试使用 readOnly=true 时,上述两个条件都不符合预期。

@Configuration
@EnableTransactionManagement
public class PersistenceJPAConfig {

    @Bean
    @Primary
    DataSource dataSource() throws PropertyVetoException {
        HikariConfig config = new HikariConfig();
        config.setJdbcUrl("jdbc:mysql://localhost:3306/db_example");
        config.setDriverClassName(Driver.class.getName());

        config.setConnectionTestQuery("SELECT 1");
        config.setUsername("root");
        config.setPassword("root1234");



        config.addDataSourceProperty("cachePrepStmts", "true");
        config.addDataSourceProperty("prepStmtCacheSize", "250");
        config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
        config.addDataSourceProperty("useServerPrepStmts", "true");
        config.setMaximumPoolSize(11);
        return new HikariDataSource(config);
    }

    @Bean
    @Primary
    public EntityManagerFactory entityManagerFactory() throws PropertyVetoException {
        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        vendorAdapter.setGenerateDdl(true);
        vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5Dialect");
        vendorAdapter.setShowSql(true);

        LocalContainerEntityManagerFactoryBean factory …
Run Code Online (Sandbox Code Playgroud)

hibernate spring-transactions spring-boot

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

HttpSecurity PermitAll 和 WebSecurity 忽略未验证 URL 的功能?

这个问题可能看起来重复,但以下答案都没有解释何时使用:

`http
   .authorizeRequests()
   .antMatchers("/h2-console/**", "/user/register/**").permitAll()` 
Run Code Online (Sandbox Code Playgroud)

`web
   .ignoring()
   .antMatchers("/h2-console/**", "/user/register/**")`
Run Code Online (Sandbox Code Playgroud)
  1. HttpSecurity、WebSecurity 和 AuthenticationManagerBuilder
  2. Spring Security 中 Web 忽略和 Http 允许之间的区别?

通过浏览 StackOverflow 的答案和几篇文章,我了解到:

configure(HttpSecurity)允许在资源级别配置基于 Web 的安全性。

configure(WebSecurity)用于影响全局安全性的配置设置。使用这个 URL 会被 Spring Security 过滤器链完全忽略。

当我使用它时permitAll(),它仅在我禁用了csrf时才有效:http.csrf().disable()因为 Spring Security 过滤器链仍然处于活动状态。

web.ignoring()URL 则被完全忽略。

还有很多文章使用http.permitAll()for/login/registerlike这样的一个这个

所以我想明白,

为什么我们应该使用http.permitAll()/login和 这样的未授权 URL /register

为什么我们不能使用web.ignoring()for/login/register

为什么 web.ignoring()通常仅用于提供静态内容,例如 …

java spring spring-mvc spring-security spring-boot

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

如何在不使用curl的情况下通过post调用将数据发送到influxdb?

我是 influxdb 的新手,我试图将数据添加到 influx db 。我在文档页面上发现可以使用curl来完成。

curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
Run Code Online (Sandbox Code Playgroud)

但我想从浏览器中点击它并能够将数据插入到 influxdb 中。

对于选择查询:

http://localhost:8086/query?db=mydb&q=select * from temperature
Run Code Online (Sandbox Code Playgroud)

这是一个可用于从 influxdb 获取数据的 url。有没有类似的方法将数据插入到 influxdb. 我尝试从curl 创建url 但没有成功。

curl http influxdb

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

如何使用Telegraf尾随远程日志文件

嗨,我是Telegraf和Influxdb的新手。我知道我们可以使用Telegraf尾随(监视)本地文件(在安装Telegraf的同一台机器上),并使用Telegraf的[[inputs.tail]]和[[outputs.influxdb]]插件将输出发送到Influxdb。

但是我想拖尾一个日志文件,该文件位于安装Telegraf之外的其他服务器上。

一种方法是将Telegraf安装在日志文件所在的服务器上:但是我不能这样做,因为该服务器无法将数据发送到Influxdb。它无权访问存在Influxdb的服务器。

因此,我必须使用中间服务器才能将数据发送到InfluxDb。

因此,有一种方法可以拖尾远程文件或其他任何方法。欢迎任何类型的建议。

tail influxdb telegraf telegraf-inputs-plugin telegraf-output-plugins

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