对于有意执行以下命令的Spring Boot
:
java -jar ./target/command-01-0.0.1-SNAPSHOT.jar --user-name=
(两个-
和=
)投掷
[main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalArgumentException: Invalid argument syntax: ---user-name=
at org.springframework.core.env.SimpleCommandLineArgsParser.parse(SimpleCommandLineArgsParser.java:75)
at org.springframework.core.env.SimpleCommandLinePropertySource.<init>(SimpleCommandLinePropertySource.java:90)
at org.springframework.boot.DefaultApplicationArguments$Source.<init>(DefaultApplicationArguments.java:76)
at org.springframework.boot.DefaultApplicationArguments.<init>(DefaultApplicationArguments.java:42)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.manuel.jordan.Command01Application.main(Command01Application.java:21)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
但是如果使用:
java -jar ./target/command-01-0.0.1-SNAPSHOT.jar -user-name=
(一个-
和=
)java -jar ./target/command-01-0.0.1-SNAPSHOT.jar --user-name
(两个-
和 not =
)通过
如果参数--user-name
使用=
并且没有值,则开发的应用程序将具有内部验证。这当然不是很关键,因为:
--user-name
或-user-name=
自变量来代替。 为什么Spring Boot
具有此控件验证?这是什么原因呢?