如何使用Java 8 --parameter标志编译Spring Boot应用程序 [英] How to compile Spring Boot applications with Java 8 --parameter flag

查看:86
本文介绍了如何使用Java 8 --parameter标志编译Spring Boot应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring文档告诉您, 如果我们使用Java 8 --parameters标志编译项目,则可以跳过在@PathVariable之类的批注中提供参数名称的操作.也就是说,我们可以只使用@PathVariable id代替@PathVariable("id") id.

Spring documentation tells that, if we compile our project using Java 8 --parameters flag, we can skip giving parameter names in annotations like @PathVariable. That means, we can just use @PathVariable id instead of @PathVariable("id") id.

在Spring Boot Maven应用程序中,我很好奇知道如何告诉编译器使用 parameters 标志.默认情况下启用吗?我们是否需要在 pom.xml 中提供一些内容?

In a Spring Boot Maven application, I was curious to know how to tell the compiler to use the parameters flag. Is it on by default? Do we need to provide something in the pom.xml?

推荐答案

在Spring Boot 2.0中,默认情况下应启用--parameters标志.参见 yuranos87的答案.

In Spring Boot 2.0, the --parameters flag should be enabled by default. See yuranos87's answer.

对于较早的版本,可以在pom.xml文件中将Java编译器选项指定为

For older versions, in the pom.xml file, you can specify Java compiler options as 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>

这篇关于如何使用Java 8 --parameter标志编译Spring Boot应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆