SpringとWebサービスを使用しています。だから私はweb.xmlを次のように定義しました
<?xml version="1.0" encoding="UTF-8"?>
<project name="service" default="deploy">
<property name="builddir" value="build" />
<property name="srcdir" value="../src" />
<property name="deploydir" value="deploy" />
<property name="wardir" value="../WebContent"/>
<property name="libdir" value="${wardir}/WEB-INF/lib/" />
<target name="cleanstart">
<delete dir="${builddir}" failonerror="true" />
<echo message="Creating build directories" />
<mkdir dir="${builddir}" />
<mkdir dir="${builddir}/service/WEB-INF/classes" />
<mkdir dir="${deploydir}" />
</target>
<target name="service.war">
<path id="basepath">
<!--<fileset dir="${libdir}">
<include name="**/*.jar" />
</fileset>
-->
<fileset dir="${wardir}/WEB-INF/lib">
<include name="**/*.jar" />
</fileset>
</path>
<javac srcdir="${srcdir}/" destdir="${builddir}/service/WEB-INF/classes">
<classpath refid="basepath" />
</javac>
<war warfile="${builddir}/service.war" webxml="${wardir}/WEB-INF/web.xml" update="update">
<classes dir="${builddir}/service/WEB-INF/classes" />
<fileset dir="${wardir}">
<exclude name="**/*web.xml" />
</fileset>
</war>
</target>
<target name="deploy" depends="cleanstart, service.war">
<copy file="${builddir}/service.war" todir="${deploydir}">
</copy>
</target>
</project>
そして、springのbeans.xmlを定義し、以下のコードを使用してSpringをロードしました。
ServletConfig servletConfig ;
ServletContext servletContext = servletConfig.getServletContext();
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
antビルド中に、次のような例外が発生しました。
service.war:
[javac] /home/vshankar/service_spring/buildTools/build.xml:36: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 20 source files to /home/vshankar/service_spring/buildTools/build/service/WEB-INF/classes
[javac] /home/vshankar/service_spring/src/com/f/a/services/servicename/Service.java:6: package javax.servlet does not exist
[javac] import javax.servlet.ServletConfig;
[javac] ^
[javac] /home/vshankar/service_spring/src/com/f/a/services/servicename/Service.java:7: package javax.servlet does not exist
[javac] import javax.servlet.ServletContext;
[javac] ^
[javac] /home/vshankar/service_spring/src/com/f/a/services/servicename/Service.java:49: cannot find symbol
[javac] symbol : class ServletConfig
[javac] location: class com.f.a.services.servicename.Service
[javac] ServletConfig servletConfig ;
[javac] ^
[javac] /home/vshankar/service_spring/src/com/f/a/services/servicename/Service.java:50: cannot find symbol
[javac] symbol : class ServletContext
[javac] location: class
com.f.a.services.servicename.Service
[javac] ServletContext servletContext = servletConfig.getServletContext();
[javac] ^
[javac] 4 errors
誰かが私を助けることができますか?