gpt4 book ai didi

spring - 如何使用 Java 8 --parameter 标志编译 Spring Boot 应用程序

转载 作者:行者123 更新时间:2023-12-02 11:24:35 25 4
gpt4 key购买 nike

Spring documentation告诉我们,如果我们使用 Java 8 --parameters 标志编译我们的项目,我们可以跳过在 @PathVariable 之类的注释中给出参数名称。这意味着,我们可以使用 @PathVariable id而不是 @PathVariable("id") id .

在 Spring Boot Maven 应用程序中,我很想知道如何告诉编译器使用参数标志。是否默认开启?我们需要在 pom.xml 中提供一些东西吗?

最佳答案

在 Spring Boot 2.0 中,--parameters默认情况下应启用标志。见 yuranos87's answer .

对于旧版本,在 pom.xml 文件中,您可以将 Java 编译器选项指定为 arguments of the Maven compiler plugin :

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>

关于spring - 如何使用 Java 8 --parameter 标志编译 Spring Boot 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31845676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com