问题
My application uses reflection in order to extract parameters names for a specific method.
I need the names like they are written in my code (and not arg0, arg1...).
In order to achieve this I go to: Windows -> Preferences -> Java -> Compiler - and mark: "Store method parameter names".
(I use JDK1.8 with Eclipse Kepler)
Now, when I do something like:
method.getParameters()[0].getName()
If I run my application with Debug Configuration = Java application --> it works fine!
BUT, if I run it with Debug Configuration = M2 Maven Build --> it doesn't work! it show the synthesize names (arg0, arg1...)
I need it to work via Maven Build, Any idea??
回答1:
Try to explicitly tell compiler that you want method parameter names to be preserved:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-g:vars</compilerArgument>
<testCompilerArgument>-g:vars</testCompilerArgument>
</configuration>
</plugin>
来源:https://stackoverflow.com/questions/24056377/run-eclipse-with-m2-maven-build-ignores-store-method-parameter-names-definitio