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

标签 java eclipse maven maven-3

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

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

相关文章:

maven - 带有 maven-bundle-plugin 的 OSGI JAR 包

maven - Fork 一个项目,Maven 到 Bintray 使用什么 groupId?

java - isKeyDown 在 Java 中不起作用

java - 仅当 bean 作为方法参数存在时,Spring 才会 Autowiring

java - 检测悬停/滑动按钮

java - Ant :找不到类:javac1.8

java - 是否可以添加 eclipse 插件 jar 作为 MAVEN 依赖项?

java - 如何添加类以在 Eclipse 中构建路径

java - 多个长按监听器

java - Maven GWT 模块与 GWT 2.8.2 + Java 11 中断