<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    kapok

    垃圾桶,嘿嘿,我藏的這么深你們還能找到啊,真牛!

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      455 隨筆 :: 0 文章 :: 76 評論 :: 0 Trackbacks
    http://m.tkk7.com/jinfeng_wang/archive/2005/04/01/2688.html

    <?
    xml version="1.0"?>
    <project name="Harnessing Hibernate: The Developer's Notebook"
             default
    ="db" basedir=".">

      
    <!-- Set up properties containing important project directories -->
      
    <property name="source.root" value="src"/>
      
    <property name="class.root" value="classes"/>
      
    <property name="lib.dir" value="lib"/>
      
    <property name="data.dir" value="data"/>

      
    <!-- Set up the class path for compilation and execution -->
      
    <path id="project.class.path">
          
    <!-- Include our own classes, of course -->
          
    <pathelement location="${class.root}" />
          
    <!-- Include jars in the project library directory -->
          
    <fileset dir="${lib.dir}">
            
    <include name="*.jar"/>
          
    </fileset>
      
    </path>

      
    <target name="db" description="Runs HSQLDB database management UI
    against the database file--use when application is not running"
    >
          
    <java classname="org.hsqldb.util.DatabaseManager"
                fork
    ="yes">
             
    <classpath refid="project.class.path"/>
             
    <arg value="-driver"/>
             
    <arg value="org.hsqldb.jdbcDriver"/>
             
    <arg value="-url"/>
             
    <arg value="jdbc:hsqldb:${data.dir}/music"/>
             
    <arg value="-user"/>
             
    <arg value="sa"/>
          
    </java>
      
    </target>

      
    <!-- Teach Ant how to use Hibernate's code generation tool -->
      
    <taskdef name="hbm2java"
               classname
    ="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
               classpathref
    ="project.class.path"/>

      
    <!-- Generate the java code for all mapping files in our source tree -->
      
    <target name="codegen"
              description
    ="Generate Java source from the O/R mapping files">
        
    <hbm2java output="${source.root}">
          
    <fileset dir="${source.root}">
            
    <include name="**/*.hbm.xml"/>
          
    </fileset>
        
    </hbm2java>
      
    </target>

      
    <!-- Create our runtime subdirectories and copy resources into them -->
      
    <target name="prepare" description="Sets up build structures">
        
    <mkdir dir="${class.root}"/>

        
    <!-- Copy our property files and O/R mappings for use at runtime -->
        
    <copy todir="${class.root}" >
          
    <fileset dir="${source.root}" >
            
    <include name="**/*.properties"/>
            
    <include name="**/*.hbm.xml"/>
          
    </fileset>
        
    </copy>
      
    </target>

      
    <!-- Compile the java source of the project -->
      
    <target name="compile" depends="prepare"
              description
    ="Compiles all Java classes">
        
    <javac srcdir="${source.root}"
               destdir
    ="${class.root}"
               debug
    ="on"
               optimize
    ="off"
               deprecation
    ="on">
          
    <classpath refid="project.class.path"/>
        
    </javac>
      
    </target>

      
    <!-- Generate the schemas for all mapping files in our class tree -->
      
    <target name="schema" depends="compile"
              description
    ="Generate DB schema from the O/R mapping files">

        
    <!-- Teach Ant how to use Hibernate's schema generation tool -->
        
    <taskdef name="schemaexport"
                 classname
    ="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
                 classpathref
    ="project.class.path"/>

        
    <schemaexport properties="${class.root}/hibernate.properties"
                      quiet
    ="no" text="no" drop="no">
          
    <fileset dir="${class.root}">
            
    <include name="**/*.hbm.xml"/>
          
    </fileset>
        
    </schemaexport>
      
    </target>

    </project>

     

    You may be wondering why the taskdef for the schema update tool is inside our schema target, rather than at the top of the build file, next to the one for hbm2java. Well, I wanted it up there too, but I ran into a snag that's worth explaining. I got strange error messages the first time I tried to build the schema target, complaining there was no hibernate.properties on the class path and our compiled Track class couldn't be found. When I ran it again, it worked. Some detective work using ant -verbose revealed that if the classes directory didn't exist when the taskdef was encountered, Ant helpfully removed it from the class path. Since a taskdef can't have its own dependencies, the solution is to move it into the schema target, giving it the benefit of that target's dependencies, ensuring the classes directory exists by the time the taskdef is processed.

    也許你會奇怪,為何找了schema更新工具的taskdef會在schema的target中進行定義,而不是在build文件的頂部,緊接著hbm2java進行定義。剛開始我也是那樣想的,這里我需要解釋一下這里的問題。當第一次構建schema時,我得到了許多莫名奇妙的錯誤,報錯信息是:在classpath中找不到hibernate.properties和Track類。但是再次構建的時候,就可以了。當使用命令“ant -verbose”時,你就可以發現其中的細節之所在。如果在ant解析到taskdef時,build文件中所使用的class目錄并不存在,那么ant就會自己將此目錄從classpath中移除。但是taskdef又無法定義自己的dependencies,因此這里不得不將其移入到schema target中,這樣也就可以使用到target的dependencies,保證在ant處理taskdef的時候,class目錄必然已經存在。

    posted on 2005-04-03 23:08 笨笨 閱讀(366) 評論(0)  編輯  收藏 所屬分類: HibernateAndSpringALL
    主站蜘蛛池模板: 亚洲精品无码专区久久同性男| 免费福利在线视频| 毛片网站免费在线观看| 67pao强力打造67194在线午夜亚洲| 91在线免费观看| 亚洲啪啪AV无码片| 国产男女爽爽爽免费视频| 国产日韩成人亚洲丁香婷婷| 一个人免费观看日本www视频| 国产成人亚洲精品影院| 久久久精品视频免费观看 | 国产一区二区三区在线免费观看 | 亚洲综合精品一二三区在线 | a级毛片100部免费观看| 久久青草亚洲AV无码麻豆| 国产精品免费福利久久| 亚洲欧洲第一a在线观看| 免费观看国产网址你懂的| 一本色道久久综合亚洲精品蜜桃冫| 成年在线网站免费观看无广告 | 四虎影视大全免费入口| 国产精品亚洲综合网站| 国产亚洲情侣一区二区无码AV| 另类免费视频一区二区在线观看| 78成人精品电影在线播放日韩精品电影一区亚洲 | 日韩精品在线免费观看| 亚洲人成免费网站| 又粗又大又猛又爽免费视频| 两个人日本免费完整版在线观看1| 亚洲最新视频在线观看| 女人张腿给男人桶视频免费版| 一道本在线免费视频| 亚洲精品免费观看| 免费看少妇作爱视频| 美女网站在线观看视频免费的| 麻豆亚洲av熟女国产一区二| 宅男666在线永久免费观看| 久久久精品视频免费观看| 亚洲无成人网77777| 免费在线一级毛片| 一级毛片成人免费看免费不卡|