1

例外:

 Caused by: org.springframework.core.NestedIOException: Failed to parse config resource: ServletContext resource [/WEB-INF/SqlMapConfig.xml]; nested exception is com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: java.io.IOException: Could not find resource WEB-INF/ADCampaignDetailsSQLMap.xml

SqlMapConfig.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL MAP Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
    <settings useStatementNamespaces="true"/>

    <sqlMap resource="WEB-INF/ADCampaignDetailsSQLMap.xml"/>
</sqlMapConfig>

ADCampaignDetailsS​​QLMap.xml 放在我的项目文件夹的 WEB-INF 中

当我将战争文件复制到 webapps 文件夹时,会引发上述异常。

谁能给我解决这个问题?

提前致谢

编辑:

构建.xml

<?xml version="1.0" encoding="UTF-8"?>
<project
    name="adblendservice"
    default="war" >

    <property environment="env" />

    <property
        name="builddir"
        value="build/" />

    <property
        name="srcdir"
        value="src/main/java/" />

    <property
        name="deploydir"
        value="deploy/" />

    <property
        name="wardir"
        value="src/main/webapp/" />

    <property
        name="libdir"
        value="${wardir}/WEB-INF/lib/" />

    <property file="build.properties" />

    <path id="project-classpath" >

        <fileset
            dir="web/WEB-INF/lib"
            includes="*.jar" />

        <fileset
            dir="${tomcat-home}/lib"
            includes="*.jar" />
        <!--
            <fileset dir="${tomcat-home}/common/lib" includes="*.jar" />
            <fileset dir="${tomcat-home}/server/lib" includes="*.jar" />
        -->
    </path>

    <target name="clean" >

        <delete
            dir="${builddir}"
            failonerror="true" />

        <echo message="Creating build directories" />
    </target>

    <target name="war" >

        <mkdir dir="${builddir}" />

        <mkdir dir="${builddir}/adblendservice/WEB-INF/classes" />

        <mkdir dir="${deploydir}" />

        <path id="basepath" >

            <fileset dir="${wardir}/WEB-INF/lib" >

                <include name="**/*.jar" />
            </fileset>
        </path>

        <javac
            destdir="${builddir}/adblendservice/WEB-INF/classes"
            includeantruntime="false"
            srcdir="${srcdir}" >

            <classpath refid="basepath" />
        </javac>

        <war
            update="update"
            warfile="${builddir}/adblendservice.war"
            webxml="${wardir}/WEB-INF/web.xml" >

            <classes dir="${builddir}/adblendservice/WEB-INF/classes" />

            <fileset dir="${srcdir}" >
                <include name="**/*.xml" />
            </fileset>

            <lib dir="${wardir}/WEB-INF/lib" />

            <fileset dir="${wardir}" >

                <include name="**/*.xml" />
            </fileset>
        </war>
    </target>

    <target
        name="deploy"
        depends="clean, war" >

        <copy
            file="${builddir}/adblendservice.war"
            todir="${deploydir}" >
        </copy>
    </target>

</project>
4

2 回答 2

1

iBatis 搜索 xml 文件的类路径的根是WEB-INF/classes,而不是公共网站的根。
尝试将您的 xml 移动到classes目录中并在没有路径的情况下指向它。

于 2012-08-11T18:46:32.897 回答
0

将您的 XML 文件移动到类路径,或者如果它在类路径之外,则指定路径,如 <sqlMap resource="../WEB-INF/ADCampaignDetailsSQLMap.xml"/>

于 2013-03-01T12:28:01.533 回答