我的应用程序使用反射来提取特定方法的参数名称。
我需要名称,就像它们写在我的代码中一样(而不是 arg0、arg1...)。
为了实现这一点,我去: Windows -> Preferences -> Java -> Compiler - 并标记:“Store method parameter names”。
(我使用 JDK1.8 和 Eclipse Kepler)
现在,当我做类似的事情时:
method.getParameters()[0].getName()
如果我使用 Debug Configuration = Java application 运行我的应用程序 --> 它工作正常!
但是,如果我使用 Debug Configuration = M2 Maven Build 运行它 --> 它不起作用!它显示综合名称(arg0,arg1 ...)
我需要它通过 Maven Build 工作,知道吗??
最佳答案
尝试明确告诉编译器您希望保留方法参数名称:
<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>
关于java - 使用 M2 Maven 构建运行 Eclipse 忽略 "Store method parameter names"定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24056377/