首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

Ant中的build.xml,该怎么处理

2012-01-20 
Ant中的build.xml?xmlversion 1.0 ?projectname springapp basedir . default usage pro

Ant中的build.xml
<?xml   version= "1.0 "?>

<project   name= "springapp "   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= "springapp "/>

        <path   id= "master-classpath ">
                <fileset   dir= "${web.dir}/WEB-INF/lib ">
                        <include   name= "*.jar "/>
                </fileset>
                <!--   We   need   the   servlet   API   classes:                 -->
                <!--       for   Tomcat   4.1   use   servlet.jar                 -->
                <!--       for   Tomcat   5.0   use   servlet-api.jar         -->
                <!--       for   Other   app   server   -   check   the   docs   -->
                <fileset   dir= "${tomcat.home}/common/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} "   target= "1.3 "   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= "${tomcat.home}/webapps/${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= "${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   -->
<!--   ==============================================================   -->

        <taskdef   name= "install "   classname= "org.apache.catalina.ant.InstallTask ">
                <classpath>
                        <path   location= "${tomcat.home}/server/lib/catalina-ant.jar "/>
                </classpath>
        </taskdef>
        <taskdef   name= "reload "   classname= "org.apache.catalina.ant.ReloadTask ">
                <classpath>
                        <path   location= "${tomcat.home}/server/lib/catalina-ant.jar "/>
                </classpath>
        </taskdef>
        <taskdef   name= "list "   classname= "org.apache.catalina.ant.ListTask ">
                <classpath>
                        <path   location= "${tomcat.home}/server/lib/catalina-ant.jar "/>
                </classpath>
        </taskdef>
        <taskdef   name= "start "   classname= "org.apache.catalina.ant.StartTask ">
                <classpath>
                        <path   location= "${tomcat.home}/server/lib/catalina-ant.jar "/>
                </classpath>
        </taskdef>
        <taskdef   name= "stop "   classname= "org.apache.catalina.ant.StopTask ">


                <classpath>
                        <path   location= "${tomcat.home}/server/lib/catalina-ant.jar "/>
                </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>


#   Ant   properties   for   building   the   springapp

deploy.path=/home/trisberg/jakarta-tomcat-4.1.24/webapps
#deploy.path=c:/Tomcat   4.1/webapps
#deploy.path=c:/bea/user_projects/domains/mydomain/applications

tomcat.home=/home/trisberg/jakarta-tomcat-4.1.24
#tomcat.home=   c:/Tomcat   4.1
tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=admin
tomcat.manager.password=tomcat


编译时出现
Buildfile:   D:\workspace\springapp\build.xml
usage:
          [echo]   springapp   build   file
          [echo]   -----------------------------------
          [echo]   Available   targets   are:
          [echo]   build           -->   Build   the   application
          [echo]   deploy         -->   Deploy   application   as   directory
          [echo]   deploywar   -->   Deploy   application   as   a   WAR   file
          [echo]   install       -->   Install   application   in   Tomcat
          [echo]   reload         -->   Reload   application   in   Tomcat
          [echo]   start           -->   Start   Tomcat   application
          [echo]   stop             -->   Stop   Tomcat   application
          [echo]   list             -->   List   Tomcat   applications
stop:

BUILD   FAILED
D:\workspace\springapp\build.xml:130:   java.io.IOException:   Server   returned   HTTP   response   code:   401   for   URL:   http://localhost:8080/manager/stop?path=%2Fspringapp

Total   time:   1   second

这个错误,不知道是什么原因


[解决办法]
web.xml中的名字
还有tomcat的地址都检查过没有错误?

热点排行