Ant jar任务包含applicationContext.xml文件

时间:2012-09-28 13:48:55

标签: java spring ant

我有一个带有main方法的spring类。在类里面我试图读取值applicationContext.xml。我的目的是将这个主类及其依赖的jar,属性文件和applicationContext.xml包装起来.Hence我的目标如下所示

 <target name="testing" depends="init">
    <property name="mech.dir" value="${target.dir}/MECHNSM" />
    <property name="mech.classes.dir" value="${mech.dir}/classes" />
    <delete dir="${mech.dir}" />
    <mkdir dir="${mech.dir}" />
    <mkdir dir="${mech.classes.dir}" />
    <copy file="${tests.dir}/Mechanism.properties"      todir="${mech.classes.dir}" overwrite="true" />
    <copy file="${tests.dir}/applicationContext.xml" todir="${mech.classes.dir}" overwrite="true" />
    <javac destdir="${mech.classes.dir}" debug="true" classpath="/jars/dependency_jars/spring-context-support-3.1.1.RELEASE.jar" classpathref="project.class.path">
        <src path="${tests.dir}"/>
        <include name="com/test/Sample.java" />
    </javac>
    <jar destfile="${retymech.dir}/retryOrderPerformPost.jar" basedir="${retymech.classes.dir}">
        <manifest>
            <attribute name="Main-Class" value="com.test.Sample"/>
        </manifest>
        <!--<zipgroupfileset dir="${lib.dir}" includes="**/*.jar" />-->
        <zipfileset src="${lib.dir}/spring-web-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-core-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/log4j.jar" />
        <zipfileset src="${lib.dir}/commons-logging-1.1.1.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-asm-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-beans-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-context-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-core-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-expression-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-web-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-oxm-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/spring-test-3.1.1.RELEASE.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/httpmime-4.1.3.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/httpclient-cache-4.1.3.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/httpcore-4.1.4.jar" includes="**/*.class" excludes="META-INF/**/*" />
        <zipfileset src="${lib.dir}/httpclient-4.1.3.jar" includes="**/*.class" excludes="META-INF/**/*" />

        <fileset dir="${tests.dir}" includes="applicationContext.xml" />
    </jar>
</target>

但是当我尝试运行Sample.jar文件时,看起来appContext文件没有被加载。我在这里做错了什么。请把你的建议发给我。

0 个答案:

没有答案