[JAVA] How to specify "-parameters" compile options added in JDK 8 (Maven, IntelliJ, Spring Tool Suite = Eclipse)

This time, I will introduce how to specify the " -parameters "compile option added in JDK 8 with Maven (Maven Compiler Plugin), IntelliJ IDEA, Spring Tool Suite (= Eclipse).

Operating environment

Maven

$ ./mvnw -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T01:41:47+09:00)
Maven home: /Users/xxx/.m2/wrapper/dists/apache-maven-3.3.9-bin/2609u9g41na2l7ogackmif6fj2/apache-maven-3.3.9
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
Default locale: ja_JP, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"

IntelliJ IDEA

IntelliJ IDEA 2016.3.4
Build #IU-163.12024.16, built on January 31, 2017
Licensed to XXXX XXXX
Subscription is active until September 21, 2017
JRE: 1.8.0_112-release-408-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Spring Tool Suite

Spring Tool Suite 

Version: 3.8.3.RELEASE
Build Id: 201612191351
Platform: Eclipse Neon.2 (4.6.2)

Maven

For Maven, just add the " -parameters "option to the configuration of the Apache Maven Compiler Plugin (https://maven.apache.org/plugins/maven-compiler-plugin/index.html).

pom.xml


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

IntelliJ IDEA

For IntelliJ IDEA, simply select "Preferences> Build, Execution, Deployment> Compiler> Java Compiler" and specify "-parameters" for "Additional command line parameters:" on the screen that appears. Be sure to ** rebuild ("Build> Rebuild") ** after changing the compile options! !!

IntelliJ-parameters.png

Spring Tool Suite(Eclipse)

For Spring Tool Suite (Eclipse), just select "Preferences> Java> Compiler" and check "Store information about method parameters (usable via reflection)" on the screen that appears. Just in case, after changing the compile options, be sure to ** rebuild ("Project> Clean ...") **! !!

STS-parameters.png

Summary

Spring and MyBatis (3.4.1+), which I often use at work, also support the -parameters option, which saves me the trouble of specifying argument names (or redundant specifications) in annotations. In the case of Spring, the mechanism to resolve the argument name from the debug information (information output when the -g option is specified) is provided independently, but it is more efficient at runtime to use the -parameters option. You can resolve the argument name. Although not mentioned this time, Kotlin, one of the JVM languages, also supports Java's -parameters equivalent compile options from 1.1. For that, I will introduce how to use (setting method) in "Kotlin 1.1 and MyBatis 3.4.1 can eliminate @Param !!". If you are interested, please refer to that as well!

Recommended Posts

How to specify "-parameters" compile options added in JDK 8 (Maven, IntelliJ, Spring Tool Suite = Eclipse)
How to include Spring Tool in Eclipse 4.6.3?
How to run JUnit in Eclipse
How to get parameters in Spark
How to set Lombok in Eclipse
How to bind request parameters in list format with bean property in Spring
[swift5] How to specify color in hexadecimal
Added slf4J + logback to Eclipse Maven project
How to specify id attribute in JSF
Maven configuration problem in Spring pom.xml in Eclipse
[For beginners] How to debug in Eclipse
[JavaFX] How to write Eclipse permissions in build.gradle
How to add a classpath in Spring Boot
How to bind to property file in Spring Boot
How to Install Oracle JDK 1.8 in Ubuntu 18.04 LTS?
How to define multiple orm.xml in Spring4, JPA2.1
How to build an executable jar in Maven
How to automatically generate a constructor in Eclipse