Shv*_*alb 3 java eclipse maven-3 maven
我的应用程序使用反射来提取特定方法的参数名称.
我需要这些名称,就像它们写在我的代码中一样(而不是arg0,arg1 ......).
为了实现这一点,我转到:Windows - > Preferences - > Java - > Compiler - 并标记:"Store method parameter names".
(我在Eclipse Kepler中使用JDK1.8)
现在,当我做类似的事情:
method.getParameters()[0].getName()
Run Code Online (Sandbox Code Playgroud)
如果我使用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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
998 次 |
| 最近记录: |