Preferences -> -6ren">
gpt4 book ai didi

java - 使用 M2 Maven 构建运行 Eclipse 忽略 "Store method parameter names"定义

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:46:47 24 4
gpt4 key购买 nike

我的应用程序使用反射来提取特定方法的参数名称。

我需要名称,就像它们写在我的代码中一样(而不是 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com