我有一个带有 main 方法的 spring 类。在课堂内我试图读取值 applicationContext.xml 。我的意图是将这个主类连同它的依赖 jars、属性文件和 applicationContext.xml 一起打包。因此我的目标如下
<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 文件时,看起来 applicationContext 文件没有被加载。我在这里做错什么了吗。请把你的建议发给我。