问题描述
环境: eclispse:3.2.1 myeclipse:5.0 GA我的eclipse的自动生成的方法里的参数都是 arg0,arg1,....., 这样可读性非常差,我记得有的eclipse生成的参数名字跟类里的成员变量的名字时一样的,这样就非常容易读懂,请问我应该怎么改,是不是跟eclipse的版本有关系?package com.alpha.spring.ch5;import org.springframework.beans.BeansException;import org.springframework.beans.factory.BeanFactory;import org.springframework.beans.factory.BeanFactoryAware;import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;import org.springframework.beans.factory.xml.XmlBeanFactory;import org.springframework.core.io.FileSystemResource;public class BeanFactoryWareImplements implements Runnable, BeanFactoryAware {private ConfigurableListableBeanFactory factory;public void setBeanFactory([color=red]BeanFactory arg0[/color]) throws BeansException {if(arg0 instanceof ConfigurableListableBeanFactory) {factory = (ConfigurableListableBeanFactory)arg0;Runtime.getRuntime().addShutdownHook(new Thread(this));}}public void run() {if(factory != null) {System.out.println("calling destroy method");factory.destroySingletons();System.out.println("called destroy method");}}}class BeanFactoryWareImplementsExample {public static void main(String[] args) {ConfigurableListableBeanFactory factory = new XmlBeanFactory(new FileSystemResource("destructvieMethod.xml"));factory.preInstantiateSingletons();factory.getBean("destructvieBean");}}
解决方案
public abstract interface BeanFactoryAware { public void setBeanFactory(BeanFactory arg0) throws BeansException;}这个和Eclipse好像没有关系的, 因为, BeanFactoryAware定义的就是arg0, 所以, Eclipse会自动带出arg0来.