Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 创建war文件时遇到的问题_Spring_Tomcat_Ant - Fatal编程技术网

Spring 创建war文件时遇到的问题

Spring 创建war文件时遇到的问题,spring,tomcat,ant,Spring,Tomcat,Ant,我在将spring应用程序部署到tomcat 7时遇到问题,出现以下错误: C:\Users\xxxxxx\Work\Online Racing League\build.xml:61:创建问题 war:C:\Program Files\Apache软件 基金会\Tomcat 7.0\webapps\Online Racing League.war(访问被拒绝) (而且档案可能已经损坏 但我无法删除它) 以下是my build.properties的外观: # Ant properties fo

我在将spring应用程序部署到tomcat 7时遇到问题,出现以下错误:

C:\Users\xxxxxx\Work\Online Racing League\build.xml:61:创建问题 war:C:\Program Files\Apache软件 基金会\Tomcat 7.0\webapps\Online Racing League.war(访问被拒绝) (而且档案可能已经损坏 但我无法删除它)

以下是my build.properties的外观:

# Ant properties for building the springapp

appserver.home=C:/Program Files/Apache Software Foundation/Tomcat 7.0
# for Tomcat 5 use $appserver.home}/server/lib
# for Tomcat 6 use $appserver.home}/lib
appserver.lib=${appserver.home}/lib/

deploy.path=${appserver.home}/webapps

tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=
tomcat.manager.password=
生成文件:

<?xml version="1.0"?>

<project name="Online Racing League" basedir="." default="usage">
    <property file="build.properties"/>

    <property name="src.dir" value="src"/>
    <property name="web.dir" value="war"/>
    <property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
    <property name="name" value="Online Racing League"/>

    <path id="master-classpath">
        <fileset dir="${web.dir}/WEB-INF/lib">
            <include name="*.jar"/>
        </fileset>
        <!-- We need the servlet API classes: -->
        <!--  * for Tomcat 5/6 use servlet-api.jar -->
        <!--  * for other app servers - check the docs -->
        <fileset dir="${appserver.lib}">
            <include name="servlet*.jar"/>
        </fileset>
        <pathelement path="${build.dir}"/>
    </path>

    <target name="usage">
        <echo message=""/>
        <echo message="${name} build file"/>
        <echo message="-----------------------------------"/>
        <echo message=""/>
        <echo message="Available targets are:"/>
        <echo message=""/>
        <echo message="build     --> Build the application"/>
        <echo message="deploy    --> Deploy application as directory"/>
        <echo message="deploywar --> Deploy application as a WAR file"/>
        <echo message="install   --> Install application in Tomcat"/>
        <echo message="reload    --> Reload application in Tomcat"/>
        <echo message="start     --> Start Tomcat application"/>
        <echo message="stop      --> Stop Tomcat application"/>
        <echo message="list      --> List Tomcat applications"/>
        <echo message=""/>
    </target>

    <target name="build" description="Compile main source tree java files">
        <mkdir dir="${build.dir}"/>
        <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
               deprecation="false" optimize="false" failonerror="true">
            <src path="${src.dir}"/>
            <classpath refid="master-classpath"/>
        </javac>
    </target>

    <target name="deploy" depends="build" description="Deploy application">
        <copy todir="${deploy.path}/${name}" preservelastmodified="true">
            <fileset dir="${web.dir}">
                <include name="**/*.*"/>
            </fileset>
        </copy>
    </target>

    <target name="deploywar" depends="build" description="Deploy application as a WAR file">
        <war destfile="${deploy.path}/${name}.war"
             webxml="${web.dir}/WEB-INF/web.xml">
            <fileset dir="${web.dir}">
                <include name="**/*.*"/>
            </fileset>
        </war>
        <copy todir="${deploy.path}" preservelastmodified="true">
            <fileset dir=".">
                <include name="*.war"/>
            </fileset>
        </copy>
    </target>



    <!-- ============================================================== -->
    <!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
    <!-- ============================================================== -->

        <path id="catalina-ant-classpath">
            <!-- We need the Catalina jars for Tomcat -->
            <!--  * for other app servers - check the docs -->
            <fileset dir="${appserver.lib}">
                <include name="catalina-ant.jar"/>
            </fileset>
        </path>

        <taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
            <classpath refid="catalina-ant-classpath"/>
        </taskdef>
        <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
            <classpath refid="catalina-ant-classpath"/>
        </taskdef>
        <taskdef name="list" classname="org.apache.catalina.ant.ListTask">
            <classpath refid="catalina-ant-classpath"/>
        </taskdef>
        <taskdef name="start" classname="org.apache.catalina.ant.StartTask">
            <classpath refid="catalina-ant-classpath"/>
        </taskdef>
        <taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
            <classpath refid="catalina-ant-classpath"/>
        </taskdef>

        <target name="install" description="Install application in Tomcat">
            <install url="${tomcat.manager.url}"
                     username="${tomcat.manager.username}"
                     password="${tomcat.manager.password}"
                     path="/${name}"
                     war="${name}"/>
        </target>

        <target name="reload" description="Reload application in Tomcat">
            <reload url="${tomcat.manager.url}"
                     username="${tomcat.manager.username}"
                     password="${tomcat.manager.password}"
                     path="/${name}"/>
        </target>

        <target name="start" description="Start Tomcat application">
            <start url="${tomcat.manager.url}"
                     username="${tomcat.manager.username}"
                     password="${tomcat.manager.password}"
                     path="/${name}"/>
        </target>

        <target name="stop" description="Stop Tomcat application">
            <stop url="${tomcat.manager.url}"
                     username="${tomcat.manager.username}"
                     password="${tomcat.manager.password}"
                     path="/${name}"/>
        </target>

        <target name="list" description="List Tomcat applications">
            <list url="${tomcat.manager.url}"
                     username="${tomcat.manager.username}"
                     password="${tomcat.manager.password}"/>
        </target>

    <!-- End Tomcat tasks -->

    </project>

servlett:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

        <mvc:annotation-driven />

    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <context:component-scan base-package="com.jr" />


</beans>

最后是web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">


    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>

        </param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


    <!-- index.htm web page -->
    <welcome-file-list>
        <welcome-file>
            index.jsp
    </welcome-file>
    </welcome-file-list>

    <!-- Register and setup my servlet xml files here -->

    <servlet>
        <servlet-name>raceLeague</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>raceLeague</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>

</web-app>     

上下文配置位置
org.springframework.web.context.ContextLoaderListener
index.jsp
赛马联盟
org.springframework.web.servlet.DispatcherServlet
赛马联盟
*.htm

看起来您在Windows Vista或Windows 7上启用了用户帐户控制()