社区版IDEA—导入Eclipse项目注意事项以及非Maven项目如何打包

经过正常导入教程之后。。。
在这里插入图片描述
有些jar包没有依赖导入,我这里直接把tomcat的lib全导入
在这里插入图片描述
将项目部署输出到tomcat的webapp目录下(注册tomcat服务可以去到bin目录执行service.bat install,如果没配置java环境变量可以直接修改service.bat,加上SET JAVA_HOME=D:\Software\jdk11.0.2),modules菜单里面可以配置编译输出位置
在这里插入图片描述
这里有个注意的地方是idea给你部署的tomcat其实是复制了一份你的tomcat配置到user文件夹下面,相当于一个service,在xml文件中可以找到具体指向哪里
在这里插入图片描述
非Maven项目如何打包——通过Ant

<?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="packWar" name="XTLHServer">
    <property environment="env"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="11"/>
    <property name="source" value="11"/>

    <!--自定义部分-->
    <property name="build" value="${basedir}/build"/>
    <property name="build.class" value="${basedir}/build/classes"/>
    <property name="src" value="${basedir}/src"/>
    <property name="web" value="${basedir}/src/main/webapp"/>
    <property name="project_jar_path" value="${web}/WEB-INF/lib"/>
    <property name="jre_jar_path" value="D:\Software\jdk11.0.2\lib"/>
    <!--<property name="jre_jar_ext_path" value="D:\Software\jdk11.0.2\lib\ext"/>-->
    <property name="tomcat_jar_path" value="D:\资料\安装的软件\apache-tomcat-8.5.73\lib"/>
    <path id="project_jar">
        <fileset dir="${project_jar_path}">
            <include name="*.jar"/>
        </fileset>
    </path>
    <path id="jre_jar">
        <fileset dir="${jre_jar_path}">
            <include name="*.jar"/>
        </fileset>
    </path>
    <!--    <path id="jre_ext_jar">
            <fileset dir="${jre_jar_ext_path}">
                <include name="*.jar"/>
            </fileset>
        </path>-->
    <path id="tomcat_jar">
        <fileset dir="${tomcat_jar_path}">
            <include name="*.jar"/>
        </fileset>
    </path>
    <path id="TARGET.classpath">
        <pathelement location="build/classes"/>
        <path refid="project_jar"/>
        <path refid="jre_jar"/>
        <!-- <path refid="jre_ext_jar"/>-->
        <path refid="tomcat_jar"/>
    </path>
    <target name="clean">
        <echo message="--------------------开始清理旧的编译文件---------------------------"/>
        <delete dir="build/classes"/>
        <delete file="${basedir}/build/${ant.project.name}.war"/>
    </target>
    <target name="init" depends="clean">
        <echo message="---------------------开始拷贝资源文件-----------------------------"/>
        <mkdir dir="build/classes"/>
        <copy includeemptydirs="false" todir="build/classes">
            <fileset dir="src/main/java">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
        <!--     <copy includeemptydirs="false" todir="build/classes">
                 <fileset dir="resources">
                     <exclude name="**/*.java"/>
                 </fileset>
             </copy>-->
    </target>
    <target name="build" depends="init">
        <echo message="-----------------------开始编译JAVA文件-----------------------------"/>
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="build/classes" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <!--<src path="resources"/>-->
            <classpath refid="TARGET.classpath"/>
        </javac>
    </target>
    <target name="packWar" depends="build">
        <echo message="-----------------------开始构建war包-----------------------------"/>
        <war destfile="${basedir}/build/${ant.project.name}.war" webxml="${web}/WEB-INF/web.xml">
            <fileset dir="${web}"/>
            <classes dir="${build.class}"/>
        </war>
    </target>

</project>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值