How to compile Spring Boot applications with Java 8 --parameter flag

后端 未结 2 1012
你的背包
你的背包 2021-01-05 14:05

Spring documentation tells that, if we compile our project using Java 8 --parameters flag, we can skip giving parameter names in annotations like @PathVariable. Tha

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-05 14:51

    I don't remember needing to do it explicitly in any of my projects. Maybe you just need to add spring-boot-starter-parent(I know, sometimes might not be an option). Otherwise, Spring has already taken care of everything for you.

    It is mentioned multiple times in Spring Boot documentation. For example, here:

    To allow the input to be mapped to the operation method’s parameters, code implementing an endpoint should be compiled with -parameters. This will happen automatically if you are using Spring Boot’s Gradle plugin or if you are using Maven and spring-boot-starter-parent.

    UPDATE

    The way Spring Boot does it is quite straight forward(in spring-boot-parent and spring-boot-starter-parent poms):

            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    ${java.version}
                    ${java.version}
                    true
                
            
    

提交回复
热议问题