2011-04-06 69 views
0

我被困在使用Spring 2.0.8(此时仍在等待签名升级),因为我不能使用注释我虽然我会使用xdoclet来生成bean我将在未来编写大量bean的配置文件。Xdoclet @ spring.bean没有正确生成配置文件

但是,当我运行我的ant目标时,它会创建xml文件,但它不包含任何bean标记。

我的Ant脚本是这样的:

<taskdef name="springdoclet" classname="xdoclet.modules.spring.SpringDocletTask"> 
    <classpath refid="springdoclet.classpath"/> 
</taskdef> 

<taskdef name="doclet" classname="xdoclet.DocletTask"> 
    <classpath refid="springdoclet.classpath"/> 
</taskdef> 

<target name="generate-spring-wiring"> 
    <springdoclet destdir="${resource.dir}" excludedtags="@version,@author,@todo"> 
     <fileset dir="${global.src.dir}"/> 
     <springxml destinationfile="spring-wiring.xml"/> 
    </springdoclet> 

</target> 

生成的XML文件是这样的:

<?xml version="1.0" encoding="UTF-8"?> 

<!DOCTYPE beans PUBLIC 
"-//SPRING//DTD BEAN//EN" 
"http://www.springframework.org/dtd/spring-beans.dtd"> 

<beans 
default-autowire="no" 
default-lazy-init="false" 
default-dependency-check="none" 
> 

<!-- 
To include additional bean definitions for Spring in the generated 
application context file, add a file to your XDoclet merge directory 
    called spring-beans.xml that contains the <bean></bean> markup. 
--> 

</beans> 

正如你可以看到没有豆已经成立。

我的bean类全部从同一个源目录中的父类继承。该MasterBean已设置如下:

/** 
* 
*@spring.bean id="master" 
*/ 
abstract public class Master implements Rule { 

.. 
.. 
} 

和样品子类(在同一个包被设置如下:

/** 
* 
* @spring.bean id="G27" 
*/ 
public class Global27_IncorrectFormTypeForCA extends Master { 

这事做的事实,我的班级扩展超?或者,我只是将它设置了不正确。这个文档是几乎不存在,因此任何帮助将感激收到。

感谢

回答

0

我公顷d有关XDoclet和文件集子任务的一些问题,如果将dir属性设置为较深(如src/java/my/pacakge/some/package),则无法正常工作,因此将其设置为src/java可以正常工作。

我知道XDoclet可以从具有超类的类生成Spring bean。我的所有项目的bean都扩展了一些其他类,但是它们的超类不是bean本身,即没有@spring.bean,它们都是正确生成的。我不确定这是否是一个问题,但由于您的主类是抽象的,它是否需要被定义为一个Spring bean? Spring确实具有abstract bean的概念,但它与抽象Java类不同。