我正在使用 spring 和 webservice 。所以我将 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
谁能帮我 ?