到 Google 资讯主页   
EasyJF首页   资料   源码   软件    论坛   网站    
   使用帮助    
    该信息为本站MyRSS系统缓存内容,部分图片及附件有可能无法正常使用.easyjf.comwww.matrix.org.cn无关,不对该信息负责.通过http://www.matrix.org.cn//resource/article/1/1446.html访问该信息的原始内容.
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   
利用Xdoclet 生成spring的配置文件
作者:ucgygah 来源:www.matrix.org.cn  发布时间:2006-02-22 17:52:18.67



最近看到xdoclet支持spring的自动生成,参考了一下以前的hibernate的代码,自己做了一个尝试,具体结果如下:
引用:
build.xml

代码:
<target name="define-tasks" description="defines custom tasks">
  <taskdef  name="springdoclet"           classname="xdoclet.modules.spring.SpringDocletTask"
            classpathref="xdoclet.classpath"/>    </target>
    <target name="springMap" depends="define-tasks" description="建立spring 的 XML文件">
        
            <springdoclet
            destdir="${build.dir}"
            mergedir="logs"
            excludedtags="@version,@author"
            addedtags="@xdoclet-generated at ${TODAY}"
            force="${xdoclet.force}" >
            <fileset dir="src/persistent"/>

            <springxml validatexml="true" />

        </springdoclet>
    </target>    


说明:ant 自动在你的destdir下生成spring.xml.mergedir参数可以包括你自己额外的bean定义,格式是<bean></bean>,文件名字必须为spring-beans.xml,如果你需要定义datasource,就可以放在这个文件里。

下面是我自己的代码例子:(我只写了一点简单的)
代码:

package com.entertop.smsplatform.persistent.hibernate;

import com.entertop.smsplatform.business.exception.CannotManipulateMoSequenceException;
import com.entertop.smsplatform.model.Mo;
import com.entertop.smsplatform.persistent.MoDAO;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Hibernate;
import net.sf.hibernate.Session;
import org.apache.log4j.Logger;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;
import org.springframework.orm.hibernate.SessionFactoryUtils;

import java.util.List;
import java.util.Properties;

public final class MoDAOHibernate extends HibernateDaoSupport implements MoDAO{
}



 
相关文章
 
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   


EasyJF.com 2006 隐私政策 使用EasyJF前必读