运行ant build后,在ear文件中找不到xml文件

时间:2015-07-28 12:29:48

标签: java ant ear

当我在浏览器地址栏上输入http://localhost:7001/ficv2.0/login时出现以下错误:

WARNING: Could not find action or result: /ficv2.0/login 
There is no Action mapped for namespace [/] and action name [login] associated with context path [/ficv2.0]. - [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)

struts.xml中:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">


<struts>
    <package name="struts2web" namespace="/" extends="struts-default">
        <action name="login" class="com.ssga.fi.cv.login.action.LoginAction">
            <result name="success">/jsp/index.jsp</result>
        </action>
    </package>
</struts>

struts.xml已放置在src目录中。

的build.xml:

<project name="ficv2.0" default="all" basedir=".">

<target name="set_env" unless="set_env" description="setup the properites.">

    <!-- All the system environment variables will be accessed by prefixing "env.". 
    To do that following property has to be set and be pointing to env -->

    <property environment="env" />
    <property name="java.home" value="${env.JAVA_HOME}" />

    <!-- Settings for global directories -->

    <property name="root.dir" value="." />
    <property name="source.dir" value="${root.dir}/src" />
    <property name="des.dir" value="${source.dir}/des" />
    <property name="build.dir" value="${root.dir}/build" />
    <property name="classes.dir" value="${build.dir}/classes" />
    <property name="webapp.dir" value="${root.dir}/WebContent" />
    <property name="lib.dir" value="${webapp.dir}/WEB-INF/lib" />

    <!-- Refers to cvs_build dir -->
    <property name="classes.jar.name" value="ficv2.0" />
    <property name="web.jar.name" value="ficv2.0-web" />
    <property name="ear.name" value="ficv2.0" />
    <property name="war.name" value="ficv2.0" />

    <!-- Class path settings -->
    <property name="struts.jars" value="${lib.dir}/struts2-core-2.3.24.jar ; ${lib.dir}/freemarker-2.3.22.jar ; 
        ${lib.dir}/xwork-core-2.3.24.jar ; ${lib.dir}/ognl-3.0.6.jar ; ${lib.dir}/commons-fileupload-1.3.1.jar; 
        ${lib.dir}/commons-io-2.2.jar; ${lib.dir}/commons-lang3-3.0.jar;${lib.dir}/javaassist-3.11.0.GA.jar;" />
    <!-- End - Class path settings -->

</target>

<target name="init" depends="set_env" description="Initializes the required directories.">
    <mkdir dir="${classes.dir}" />
    <mkdir dir="${webapp.dir}" />
    <mkdir dir="${webapp.dir}/WEB-INF/lib" />
    <mkdir dir="${build.dir}/war" />
    <path id="project.class.path">
        <fileset dir="${lib.dir}">
            <include name="*.jar" />
        </fileset>
    </path>
</target>

<target name="clean" depends="set_env" description="Clean up the output directories and jar.">
    <echo message="Deleting Compiled Code..." />
    <delete dir="${classes.dir}" />
    <echo message="Deleting Copied Directories..." />
    <delete dir="${build.dir}/${ear.name}.ear" />
    <delete dir="${build.dir}/${war.name}.war" />
    <delete dir="${build.dir}/war" />
</target>

<target name="compile" depends="init" description="Compiles all source files">
    <javac debug="on" srcdir="${source.dir}" destdir="${classes.dir}" verbose="true" classpath="${struts.jars}">
    </javac>
</target>

<target name="create_jar" depends="compile" description="Package the Java classes into a jar.">
    <echo message="Creating Jar file..." />
    <delete file="${webapp.dir}/WEB-INF/lib/${classes.jar.name}.jar" />
    <delete file="${webapp.dir}/WEB-INF/lib/${web.jar.name}.jar" />
    <jar jarfile="${webapp.dir}/WEB-INF/lib/${web.jar.name}.jar" basedir="${classes.dir}" includes="**/action/**" />
</target>

<target name="create_war">
    <delete file="${build.dir}/${war.name}.war" />
    <echo message="${webapp.dir}" />
    <jar jarfile="${build.dir}/${war.name}.war" update="yes" manifest="${webapp.dir}/META-INF/MANIFEST.MF">
        <fileset dir="${webapp.dir}">
            <include name="**" />
        </fileset>
        <zipfileset dir="${webapp.dir}/images" prefix="images">
            <include name="**" />
        </zipfileset>
    </jar>
</target>

<target name="create_ear" depends="create_war">
    <delete file="${build.dir}/${ear.name}.ear" />
    <ear earfile="${build.dir}/${ear.name}.ear" appxml="${root.dir}/META-INF/application.xml">
        <fileset dir="${build.dir}">
            <include name="*.jar" />
        </fileset>
        <fileset file="${build.dir}/${war.name}.war" />
    </ear>
</target>

<target name="all" depends="set_env, create_jar, create_ear" description="Perform all targets." />

</project>

运行ant build之后,我在耳朵文件中看不到struts.xml
它将存储在ficv2.0/build/classes文件夹下。

请让我知道需要在build.xml中更新哪些内容,因此,struts.xml将会出现在{i}生成的内容中。上述问题已经解决。

0 个答案:

没有答案