小编Che*_*rry的帖子

为什么 LocalDateTime 采用区域偏移量格式?

考虑代码:

public static void main(String[] args) {
  System.out.println(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH")));
}
Run Code Online (Sandbox Code Playgroud)

输出为2022-05-04-17UTC 时间2022-05-04-10。文档说这LocalDateTime是没有区域偏移的 - 那么为什么会有 7 小时轮班呢?(我当地的时区是+7UTC

java java-time

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

使用sc create将带有额外参数的.exe作为windows服务运行

我正在尝试在命令提示符下运行:

sc create mynewservice binpath="C:\Program Files\Arelle\arelleCmdLine.exe" --webserver localhost:10100

这不会成功,因为:optionname中有.

我似乎无法找到正确的合成语

service command-prompt arelle

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

是否有一种从文件中读取前n行的实用方法?

我搜索了以下受欢迎的库:

  • 番石榴 - Fiels.readLines
  • nio - Files.readFirstLineFiles.readAllLines
  • ApacheCommons - FileUtils.readLines

所有方法都将整个文件作为String集合读入内存.但这对于拥有数千行的大型文件没有用处?是否有一个简单的方法调用来读取n任何这些库中的文件的第一行?

java string file

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

如何从akka演员获得演员的物理路径?

这是演员代码:

import akka.actor.Actor

class OneActor extends Actor {
    def receive = {
        //what I should call here to get ?
        case _  => println(physicalPaht)
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以使用一些"内置"变量:

  • 上下文 - 但它不包含任何有用的路径方法
  • actorPath - 仅包含本地路径

有任何想法吗?

更新

也是一个self.path.address但它只返回root actor的路径.

scala path actor akka

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

如何在厨师中运行具有依赖性的食谱?

我已经开始配置工作站这个步骤(OS redhat 6.5).我已经启动了一个节点.我修改了这样的食谱:

myCookbook/metadata.rb

name             'myCookbook'
maintainer       'YOUR_COMPANY_NAME'
maintainer_email 'YOUR_EMAIL'
license          'All rights reserved'
description      'Installs/Configures myCookbook'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version          '0.1.0'

depends 'maven'
Run Code Online (Sandbox Code Playgroud)

例如,执行depends 'maven'后只添加了字符串knife cookbook create myCookbook.

myCookbook /食谱/ default.rb

maven 'spring-context' do
  group_id 'org.springframework'
  version  '4.0.4.RELEASE'
  dest     '/root/chef-repo/'
  repositories ['http://repo.maven.apache.org/maven2/']
end
Run Code Online (Sandbox Code Playgroud)

然后我跑:

knife cookbook upload myCookbook
Run Code Online (Sandbox Code Playgroud)

现在我想:

knife bootstrap 192.168.1.37 --ssh-user root --ssh-password '123456' --sudo --use-sudo-password --node-name node-with-maven-run --run-list 'recipe[myCookbook]'
Run Code Online (Sandbox Code Playgroud)

得到:

ERROR: Cookbook myCookbook depends on cookbooks which are not currently …
Run Code Online (Sandbox Code Playgroud)

ruby java cookbook maven chef-infra

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

在编写场景之前,cassandra应该用于阅读吗?

从cassandra规范段落之前的阅读告诉写入之前的读取对cassandra性能有一点影响.但存储引擎告诉cassandra本身在写入方案之前避免读取.

在我的情况下,我需要阅读行上的"see"并依赖条件将其写回.所以总的来说cassandra是否适用于这种场景?

java read-write cassandra

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

在kotlin中是否有Future.sequence类似物?

在scala中,你可以将未来的集合"映射"到集合的未来:

val l: List[Future[String]]  = List(Future {"1"}, Future {"2"})
val x: Future[List[String]] = Future.sequence(l)
Run Code Online (Sandbox Code Playgroud)

如何用kotlin同样的事情?

scala future kotlin completable-future

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

如何在Kotlin中从java类型数组中获取javaclass?

对于pojo课程:

//java
MyClass.getClass();
//kotlin
MyClass::class.java
Run Code Online (Sandbox Code Playgroud)

但是如何从数组中获取getClass?

//java
MyClass[].class;
//kotlin
???
Run Code Online (Sandbox Code Playgroud)

MyClass[]::class.java - 不起作用:(

java arrays kotlin

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

如何为`javax.validation.constraints` 注释添加自定义验证器?

我已经实现了Long字段和@PastOrPresent验证的验证

public class PastOrPresentValidator implements ConstraintValidator<PastOrPresent, Long>{
    @Override
    public boolean isValid(Long value, ConstraintValidatorContext context) {
        if (value == null) {
            return false;
        }
        return value <= System.currentTimeMillis();
    }
}

public class MyDto {
    @PastOrPresent
    Long timestamp;    
}
Run Code Online (Sandbox Code Playgroud)

并得到错误:

HV000030: No validator could be found for constraint 'javax.validation.constraints.PastOrPresent' validating type 'java.lang.Long'. Check configuration for 'push.dto.timestamp'
Run Code Online (Sandbox Code Playgroud)

但是当我创建自定义注释@PastOrPresentLong并使用相同的验证器代码时,一切正常。

有没有办法为javax.validation.constraints注释添加自定义验证器?

java bean-validation spring-validator

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

cloudformation Sub 函数中的“|-”是什么意思?

考虑示例(来源

  # State machine for testing Athena Runner
  AthenaRunnerTestETLOrchestrator:
    Type: "AWS::StepFunctions::StateMachine"
    Properties:
      StateMachineName: AthenaRunnerTestETLOrchestrator
      DefinitionString:
        Fn::Sub:
          - |-
            {
              "StartAt": "Configure Athena Query",
              "States": {
                "Configure Athena Query":{
                  "Type": "Pass",
                  "Result": "{ \"AthenaQueryString\" : \"SELECT * FROM ${GlueTableName} limit 10;\", \"AthenaDatabase\": \"${GlueDatabaseName}\", \"AthenaResultOutputLocation\": \"${AthenaResultOutputLocation}\", \"AthenaResultEncryptionOption\": \"${AthenaResultEncryptionOption}\"}",
                  "Next": "Execute Athena Query"
                },
                "Execute Athena Query":{
                  "Type": "Task",
                  "Resource": "${AthenaRunnerActivityArn}",
                  "End": true
                }
              }
            }
          - {
            GlueDatabaseName: !Ref MarketingAndSalesDatabaseName,
            GlueTableName: !Ref MarketingTableName,
            AthenaRunnerActivityArn: !Ref AthenaRunnerActivity,
            AthenaResultOutputLocation: !Sub "s3://${SourceDataBucketName}/athena-runner-output/",
            AthenaResultEncryptionOption: …
Run Code Online (Sandbox Code Playgroud)

yaml amazon-web-services aws-cloudformation

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