web project源代码如下:

 

一、导入项目

1.将上述代码拷贝到d:\test3文件夹下面,并将以下classpath、 project、  settings三个文件夹删除

2.新建一个动态web  project,路径为D:\TEST3

引用刚才的project到空间里,会提示错误:D:\test3\easyshopping overlaps the location of another project: \’easyshopping\’

解决方法:

D:\test3\easyshopping 里面的文件夹拷贝到D:\test3\aa\easyshopping里面,问题便可解决

 3.源码出现乱码,解决方法

4.因为没有引用相关JAR包,所以会出现如下错误

右击项目选择—build path—-configure build path

5.选择libraries—-add library添加一个user library,名称取名为lib

往刚才创建的lib中添加jar包,jar包路径为刚才源代码路径F:\easyshopping\easyshopping2\WebContent\WEB-INF\lib

全选所有的JAR包添加以后如图

6.至此上述提示的错误已经解决了,下面还有这错误没解决,提示错误如下

Access restriction: The type BASE64Decoder is not accessible due to  restriction on required library C:\Program Files (x86)\Java\jre7\lib \rt.jar

 

原因是:这个javaSE-1.7中的rt.jar包中没有sun.misc.base64decoder;(注意java1.6也没有)

安装jdk-7u5-windows-x64

删除旧的JRE

 

添加一个新的JRE System Library

选择Alternate JRE,此处也可以单击installed jres

确定后,错误解决了

 

二、使用Ant plugin 打包

右击项目–选择EXPORT—选择Ant Buildfiles

完成后会多了一个build.xml文件

XML内容如下:

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?>
<!– WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. 
–>
<project basedir=”.” default=”build” name=”easyshopping”>
    <property environment=”env”/>
    <property name=”ECLIPSE_HOME” value=”E:/eclipse”/>
    <property name=”debuglevel” value=”source,lines,vars”/>
    <property name=”target” value=”1.6″/>
    <property name=”source” value=”1.6″/>
    <path id=”Web App Libraries.libraryclasspath”>
        <pathelement location=”WebContent/WEB-INF/lib/IKAnalyzer3.2.8.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/activation-1.1.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/aliyun-openservices-1.2.2.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/antlr-2.7.7.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/aopalliance-1.0.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/asm-all-3.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/bcprov-jdk15on-1.50.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/c3p0-0.9.2.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/cglib-3.0.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/common-annotations-3.0.0.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/commons-beanutils-1.8.3.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/commons-codec-1.6.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/commons-collections-3.2.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/commons-fileupload-1.2.2.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/commons-io-2.2.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/commons-lang-2.6.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/commons-logging-1.1.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/commons-net-3.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/dom4j-1.6.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/ehcache-core-2.5.7.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/ehcache-web-2.0.4.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/freemarker-2.3.19.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/hamcrest-all-1.3.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/hibernate-search-3.4.2.Final.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/hibernate-validator-4.2.0.Final.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/hibernate3.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/httpclient-4.2.3.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/httpcore-4.2.2.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/im4java-1.4.0.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jackson-annotations-2.1.4.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jackson-core-2.1.4.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jackson-databind-2.1.4.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/javassist-3.15.0-GA.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jaxen-1.1.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jaxme-api-0.3.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jcaptcha-1.0-all_new.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jdom-1.1.3.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jsoup-1.7.2.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/jta-1.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/junit-dep-4.10.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/log4j-1.2.16.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/lucene-core-3.5.0.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/mail-1.4.4.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/mchange-commons-java-0.2.3.4.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/mysql-connector-java-5.1.25.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/pjl-comp-filter-1.7.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/poi-3.8.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/servlet-api-5.5.23.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/shiro-all-1.2.1.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/slf4j-api-1.6.4.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/slf4j-log4j12-1.6.4.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-aop-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-beans-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-context-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-context-support-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-core-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-expression-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-jdbc-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-orm-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-test-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-tx-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-web-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/spring-webmvc-3.2.2.RELEASE.jar”/>
        <pathelement location=”WebContent/WEB-INF/lib/validation-api-1.0.0.GA.jar”/>
        <pathelement location=”WebContent/WEB-INF/classes”/>
    </path>
    <path id=”EAR Libraries.libraryclasspath”/>
    <path id=”easyshopping.classpath”>
        <pathelement location=”build/classes”/>
        <path refid=”Web App Libraries.libraryclasspath”/>
        <path refid=”EAR Libraries.libraryclasspath”/>
    </path>
    <target name=”init”>
        <mkdir dir=”build/classes”/>
        <copy includeemptydirs=”false” todir=”build/classes”>
            <fileset dir=”src”>
                <exclude name=”**/*.java”/>
            </fileset>
        </copy>
    </target>
    <target name=”clean”>
        <delete dir=”build/classes”/>
    </target>
    <target depends=”clean” name=”cleanall”/>
    <target depends=”build-subprojects,build-project” name=”build”/>
    <target name=”build-subprojects”/>
    <target depends=”init” name=”build-project”>
        <echo message=”${ant.project.name}: ${ant.file}”/>
        <javac debug=”true” debuglevel=”${debuglevel}” destdir=”build/classes” source=”${source}” target=”${target}”>
            <src path=”src”/>
            <classpath refid=”easyshopping.classpath”/>
        </javac>
    </target>
    <target description=”Build all projects which reference this project. Useful to propagate changes.” name=”build-refprojects”/>
    <target description=”copy Eclipse compiler jars to ant lib directory” name=”init-eclipse-compiler”>
        <copy todir=”${ant.library.dir}”>
            <fileset dir=”${ECLIPSE_HOME}/plugins” includes=”org.eclipse.jdt.core_*.jar”/>
        </copy>
        <unzip dest=”${ant.library.dir}”>
            <patternset includes=”jdtCompilerAdapter.jar”/>
            <fileset dir=”${ECLIPSE_HOME}/plugins” includes=”org.eclipse.jdt.core_*.jar”/>
        </unzip>
    </target>
    <target description=”compile project with Eclipse compiler” name=”build-eclipse-compiler”>
        <property name=”build.compiler” value=”org.eclipse.jdt.core.JDTCompilerAdapter”/>
        <antcall target=”build”/>
    </target>
</project>

View Code

 修改如下:详细见黄色字,紫色字是忽略的

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no”?>
<!– WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. 
–>
<project basedir=”.” default=”build” name=”easyshopping”>
    <property environment=”env” />
    <property name=”ECLIPSE_HOME” value=”E:\eclipse” />
    <property name=”debuglevel” value=”source,lines,vars” />
    <property name=”target” value=”1.6″ />
    <property name=”source” value=”1.6″ />
    <property name=”dist” location=”dist”/>
    <path id=”Web App Libraries.libraryclasspath”>
        <pathelement location=”WebContent/WEB-INF/lib/IKAnalyzer3.2.8.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/activation-1.1.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/aliyun-openservices-1.2.2.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/antlr-2.7.7.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/aopalliance-1.0.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/asm-all-3.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/bcprov-jdk15on-1.50.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/c3p0-0.9.2.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/cglib-3.0.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/common-annotations-3.0.0.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/commons-beanutils-1.8.3.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/commons-codec-1.6.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/commons-collections-3.2.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/commons-fileupload-1.2.2.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/commons-io-2.2.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/commons-lang-2.6.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/commons-logging-1.1.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/commons-net-3.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/dom4j-1.6.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/ehcache-core-2.5.7.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/ehcache-web-2.0.4.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/freemarker-2.3.19.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/hamcrest-all-1.3.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.1.Final.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/hibernate-search-3.4.2.Final.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/hibernate-validator-4.2.0.Final.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/hibernate3.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/httpclient-4.2.3.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/httpcore-4.2.2.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/im4java-1.4.0.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jackson-annotations-2.1.4.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jackson-core-2.1.4.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jackson-databind-2.1.4.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/javassist-3.15.0-GA.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jaxen-1.1.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jaxme-api-0.3.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jcaptcha-1.0-all_new.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jdom-1.1.3.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jsoup-1.7.2.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/jta-1.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/junit-dep-4.10.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/log4j-1.2.16.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/lucene-core-3.5.0.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/mail-1.4.4.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/mchange-commons-java-0.2.3.4.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/mysql-connector-java-5.1.25.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/pjl-comp-filter-1.7.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/poi-3.8.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/servlet-api-5.5.23.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/shiro-all-1.2.1.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/slf4j-api-1.6.4.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/slf4j-log4j12-1.6.4.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-aop-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-beans-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-context-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-context-support-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-core-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-expression-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-jdbc-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-orm-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-test-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-tx-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-web-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/spring-webmvc-3.2.2.RELEASE.jar” />
        <pathelement location=”WebContent/WEB-INF/lib/validation-api-1.0.0.GA.jar” />
    </path>
    <path id=”easyshopping.classpath”>
        <pathelement location=”build/classes” />
        <path refid=”Web App Libraries.libraryclasspath” />
    </path>
    <target name=”init”>
        <mkdir dir=”build/classes” />
        <copy includeemptydirs=”false” todir=”build/classes”>
            <fileset dir=”src”>
                <exclude name=”**/*.java” />
            </fileset>
        </copy>
    </target>
    <target name=”clean”>
        <delete dir=”build/classes” />
    </target>
    <target depends=”clean” name=”cleanall” />
    <!–<target depends=”build-subprojects,build-project” name=”build/classes” /> –>
    <target depends=”dist” name=”build”/>
    <target name=”build-subprojects” />
    <target depends=”init” name=”build-project”>
        <echo message=”${ant.project.name}: ${ant.file}” />
        <javac debug=”true” debuglevel=”${debuglevel}” destdir=”build/classes” includeantruntime=”false” source=”${source}” target=”${target}”>
            <src path=”src” />
            <classpath refid=”easyshopping.classpath” />
        </javac>
    </target>
    <target name=”dist” depends=”build-subprojects,build-project” description=”generate the distribution”>
        <!– 創建放置jar檔目錄 –>
        <mkdir dir=”${dist}/lib” />
        <!– 把build目錄內的所有檔案結構打包成一個{ant.project.name}包  –>
        <echo message=”${dist}\lib\${ant.project.name}.jar” />
        <jar jarfile=”${dist}\lib\${ant.project.name}.jar” basedir=”build/classes” />

    </target>
    <target description=”Build all projects which reference this project. Useful to propagate changes.” name=”build-refprojects” />
    <target description=”copy Eclipse compiler jars to ant lib directory” name=”init-eclipse-compiler”>
        <copy todir=”${ant.library.dir}”>
            <fileset dir=”${ECLIPSE_HOME}/plugins” includes=”org.eclipse.jdt.core_*.jar” />
        </copy>
        <unzip dest=”${ant.library.dir}”>
            <patternset includes=”jdtCompilerAdapter.jar” />
            <fileset dir=”${ECLIPSE_HOME}/plugins” includes=”org.eclipse.jdt.core_*.jar” />
        </unzip>
    </target>
    <target description=”compile project with Eclipse compiler” name=”build-eclipse-compiler”>
        <property name=”build.compiler” value=”org.eclipse.jdt.core.JDTCompilerAdapter” />
        <antcall target=”build” />
    </target>
</project>

 3.將滑鼠指標移動到build.xml圖示,單點滑鼠右鍵後選取”Run As -> 1 Ant Build”項目執行,會於”Console”輸出Ant

posted on
2016-01-12 15:05 
Snowfun 
阅读(6309
评论(0
编辑 
收藏 
举报

版权声明:本文为Snowfun原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/Snowfun/articles/5124381.html