Run Eclipse with M2 Maven build ignores “Store method parameter names” definition

主宰稳场 提交于 2019-12-21 20:17:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!