小编api*_*nes的帖子

正则表达式匹配没有特定顺序的组

我有 4 个复杂的正则表达式模式ABCD。我需要找到所有格式的模式,A(B AND C AND D)其中的顺序B,C,D无关紧要C并且D是可选的。有没有办法在正则表达式中做这样的事情,而无需在它们之间写出所有可能的B,C,Dwith 或 ( |)排列?

我正在用 Java 编程,并且更喜欢性能友好。谢谢!

编辑:将 3 个复杂的模式更改为 4 个复杂的正则表达式模式。

java regex

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

@DataJpaTest 不读取 spring.jpa.* 属性,而 @SpringBootTest 读取

我正在使用 Spring Boot 2.0.4.RELEASE,并配置src/test/resources/application.yml

spring:
  jpa:
    show-sql: false
    hibernate:
      dialect: org.hibernate.dialect.SQLServer2012Dialect
      ddl-auto: none
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
      properties:
        hibernate:
          generate_statistics: false
          show_sql: false
Run Code Online (Sandbox Code Playgroud)

我有一个非常简单的测试:

@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@ExtendWith(SpringExtension.class)
public class MyTest {
  ...
}
Run Code Online (Sandbox Code Playgroud)

测试忽略属性(可以很容易地看到它打印休眠语句)。将相同的属性放在一个application.properties文件中是有效的。

将名称更改为application-test.yml并在配置文件测试上运行也无济于事。

当将@DataJpaTest注释更改为@SpringBootTest它的工作...

重要的是要注意其余的属性(与我的应用程序特别相关并且没有spring.*前缀的东西正在被正常读取和使用

我确实更喜欢使用 yaml 文件(如 in /src/main/resources),而不是@SpringBootTest仅为纯 JPA 测试加载完整的文件......还有什么可以配置的吗?

java spring hibernate spring-data-jpa spring-boot

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

Spring boot 2 enabling a non-secure /health endpoint

我有一个带有客户端和服务器身份验证的 Spring Boot 2 项目,我试图只公开/actuator/health端点,因此它不需要任何身份验证。

我的最初WebSecurityConfigurerAdapter是:

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
...
    private void configureWithSsl(@NotNull HttpSecurity http) throws Exception {
        LOG.info("configuring access with ssl");
        http
                .csrf().disable()
                .authorizeRequests()
                .anyRequest().authenticated()
                .and().x509()
                .and().userDetailsService(userDetailsService());
    }
...
}
Run Code Online (Sandbox Code Playgroud)

application.yaml

server:
  port: 8443
  ssl:
    enabled: true
    key-store: 'paht/to/kestore/keystore.jks'
    key-store-password: 123456
    key-store-type: JKS
    client-auth: need
    trust-store: 'paht/to/truststore/truststore.jks'
    trust-store-type: JKS
    trust-store-password: 123456
    protocol: TLS
    enabled-protocols: TLSv1.2
Run Code Online (Sandbox Code Playgroud)

我尝试过: 1. 将“通道”配置为端点不安全

    private void configureWithSsl(HttpSecurity http) throws Exception {
        http
                .csrf().disable()
                .requiresChannel().requestMatchers(EndpointRequest.to("health")).requiresInsecure()
                .and()
                .authorizeRequests() …
Run Code Online (Sandbox Code Playgroud)

java ssl spring-security spring-boot spring-boot-actuator

5
推荐指数
2
解决办法
4009
查看次数

jq:将嵌套对象添加到 JSON

我有一个包含多个配置文件的 json 文件:

{
  "profile1": {
    "user": "user1",
    "channel": "channel1",
    "hook": "hook1"
  },
  "default": {
    "user": "user1",
    "channel": "channel1",
    "hook": "hook2"
  }
}
Run Code Online (Sandbox Code Playgroud)

我想使用 jq 插入另一个配置文件“test”,这样最终结果将是

{
  "profile1": {
    "user": "user1",
    "channel": "channel1",
    "hook": "hook1"
  },
  "default": {
    "user": "user1",
    "channel": "channel1",
    "hook": "hook2"
  },
  "test": {
    "user": "user3",
    "channel": "channel3",
    "hook": "hook3"
  }
}
Run Code Online (Sandbox Code Playgroud)

我可以直接在命令行中执行以下操作:

cat filename | 
    jq  '.+  { "test": { "user": "u3", "channel" : "c3", "hook": "w3" } }'
Run Code Online (Sandbox Code Playgroud)

但是当我在 bash 脚本中尝试它时:

cat "$CONF_FILE" | 
    jq …
Run Code Online (Sandbox Code Playgroud)

bash json jq

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

AWS ECS 长期运行的作业缩减

我在 ECS 中的容器上运行了长时间运行的作业。当自动缩放触发缩放时,有没有办法告诉 ECS 在 X 时间内(或直到触发事件)不终止任务,以便作业可以完成然后才终止?

假设我在 10 个实例上有 10 个容器,其中 3 个正在运行作业,我希望 ECS 不终止这些实例,并仅考虑剩余 7 个实例的规模。ECS支持这样的东西吗?

amazon-ec2 amazon-web-services amazon-ecs

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