在做某事的时候,我偶然发现了这段代码:
if(true) {
String message = "Assignment possible";
}
if(true)
String message = "Time to leave earth"; // error!
Run Code Online (Sandbox Code Playgroud)
为什么在第二种情况下可以在没有括号的情况下在java中写入"if"条件时出现编译错误?
错误消息似乎没有给出正确的信息:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error, insert ":: IdentifierOrNew" to complete ReferenceExpression
Syntax error, insert "AssignmentOperator Expression" to complete Assignment
Syntax error, insert ";" to complete Statement
String cannot be resolved to a variable
message cannot be resolved to a variable
Run Code Online (Sandbox Code Playgroud)
我错过了一些明显的东西吗?有人可以解释一下吗?
我需要将多个参数传递给 Maven 命令行以运行 Spring Boot 应用程序。这就是我在 Spring Boot 中传递命令行参数的方式。我正在使用 spring boot 2.2.6 Release
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8999,--spring.application.instance_id=dhn"
但是我收到以下错误
nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server.port' to java.lang.Integer
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'server.port' to java.lang.Integer:
Property: server.port
Value: 8999,--spring.application.instance_id=dhn
Origin: "server.port" from property source "commandLineArgs"
Reason: failed to convert java.lang.String to java.lang.Integer
Action:
Update your application's configuration
Run Code Online (Sandbox Code Playgroud)
似乎参数没有正确解析