我正在编写用于部署Java应用程序的脚本。场景很简单:
如何从Maven仓库下载此jar到本地文件夹?
重要
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:copy将失败,因为它仅在pom.xml存在的文件夹中运行。喷雾文档有关于onComplete指令的示例
我复制了例子:
path("divide" / IntNumber / IntNumber) { (a, b) =>
onComplete(divide(a, b)) {
case Success(value: Any) => complete(s"The result was $value")
case Failure(ex) => complete(StatusCodes.InternalServerError, s"An error occurred: ${ex.getMessage}")
}
}
def divide(a: Int, b: Int): Future[Int] = Future {
a / b
}
Run Code Online (Sandbox Code Playgroud)
我得到了错误:
Type mismatch, expected: onCompleteFutureMagnet[NoninferedT], actual Future[Int]
Run Code Online (Sandbox Code Playgroud)
似乎在代码中遗漏了一些非常简单的东西.
喷涂版本为1.3.1
更新
我已经下载了喷雾源并在FutureDirectivesSpec中看到了相同的编译错误.
我试图指定val常量只对一个对象可见:
object Config {
private[my.pack.MyObject] val Some = Option("String")
}
// in package my.pack
object MyObject {
val Other = Config.Some
}
Run Code Online (Sandbox Code Playgroud)
在编译时我得到一个错误:
[error] C:\path\Config.scala:17: ']' expected but '.' found.
[error] private[my.pack.MyObject] val Some = Option("String")
[error] ^
Run Code Online (Sandbox Code Playgroud)
怎么了?当我读到访问限定符时,它们可以是类或对象,而不是包,我错了吗?
考虑一个代码(不可编译):
List<String> list = Arrays.asList("a", "b");
list.stream().map(s ->
String variable = method(s)
variable + "debug"
);
private String method(String s) {
return s;
}
Run Code Online (Sandbox Code Playgroud)
线String variable = method(s)未编译.
我可以在 lambda表达式中定义局部变量,还是被设计禁止?
我从arelle.org下载了xbrldb_SEC_pg_2014-11-02.pg.gzip postgres pg_dump文件.然后,我在pgAdminIII中运行了架构ddl文件,并重新创建了所有数据库,函数等.
当我尝试使用以下内容还原数据库时:
desktop:~/Downloads$ sudo postgres zcat xbrldb_SEC_pg_2014-11-02.pg.gzip | psql -U postgres public
Run Code Online (Sandbox Code Playgroud)
我明白了:
sudo: postgres: command not found psql: FATAL: Peer authentication failed for user "postgres"
Run Code Online (Sandbox Code Playgroud)
我可以将文件zcat转换为文件来扩展它.看起来它是一个pg_dump文件.
postgres=> pg_restore -a /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.txt
postgres-> ;
ERROR: syntax error at or near "pg_restore"
LINE 1: pg_restore -a /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-0...
^
postgres=> pg_restore -a postgres /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.txt;
ERROR: syntax error at or near "pg_restore"
LINE 1: pg_restore -a postgres /home/jeremy/Downloads/xbrldb_SEC_pg_...
Run Code Online (Sandbox Code Playgroud)
那么我尝试使用PG Admin III和我的输出:
/usr/bin/pg_restore --host localhost --port 5432 --username "postgres" --dbname "public" --role "postgres" …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Spring Boot 运行集成测试并收到以下错误:
Caused by: org.springframework.context.ApplicationContextException:
Failed to start bean 'SchedulerFactory'; nested exception is org.springframework.scheduling.SchedulingException:
Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException:
Failure occured during job recovery. [See nested exception:
org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM QRTZ_LOCKS UPDLOCK WHERE LOCK_NAME = ? [42102-193] [See nested exception: org.h2.jdbc.JdbcSQLException: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM QRTZ_LOCKS UPDLOCK WHERE LOCK_NAME = ? [42102-193]]]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:176)
Run Code Online (Sandbox Code Playgroud)
很明显,QRTZ表没有创建。我 …
有一个带有 h2 数据库的 spring boot 应用程序,用作主数据库。还有一个resource/schema.sql在启动时通过 spring boot 加载的。
但是在使用@SpringBootTestspring boot 的集成测试期间不会加载这个schema.sql。相反,它需要在h2已经有db 的情况下设置嵌入式数据库。
有没有办法在schema.sql没有嵌入数据源配置的情况下执行?并且只对所有测试执行一次(例如@Sql,用于所有测试的模式创建不是解决方案)?
考虑代码示例:
val contentLength :Long? = 1
val float = contentLength?.toFloat()
val any = (float ?: 0) * 1.25
// ^
// compilation error here
Run Code Online (Sandbox Code Playgroud)
如果我尝试像这样提取变量herem:
val casted = (float ?: 0)
Run Code Online (Sandbox Code Playgroud)
IDE显示casted具有Any类型.为什么会这样?如何从浮点引用中获取nullsafe浮点值并将其乘以另一个浮点值?
更新
替换0为0.0:
(float ?: 0.0)
Run Code Online (Sandbox Code Playgroud)
没有效果.:(
考虑这个例子:
aws cognito-idp admin-update-user-attributes --user-pool-id myUserPollId
--username myUser
--user-attributes [{"Name": "custom:roles","Value": "ROLE1,ROLE2"}] --region us-east-1
Run Code Online (Sandbox Code Playgroud)
这给我带来了错误:
Invalid JSON:
[{Name:
Run Code Online (Sandbox Code Playgroud) 例如,我运行ETL,可能为目标表添加了新的字段或列。要检测表更改,应运行搜寻器,但只能手动或按计划运行。
作业完成后可以触发搜寻器吗?