美文网首页maven
eclipse 使用 maven 构建项目

eclipse 使用 maven 构建项目

作者: _换个昵称试试 | 来源:发表于2017-09-28 21:26 被阅读0次

    环境准备

    Maven基本配置 修改 setting.xml 文件

    apache-tomcat-8.5.20/conf/settings.xml

    1.仓库本地存储位置

    本地仓库位置

    2.配置阿里云国内的中央仓库,提升下载速度 mirrors 节点内

    <mirror>
            <!-- 配置 阿里云 maven 镜像仓库,提升国内下载速度 -->
            <id>alimaven</id>
                <mirrorOf>central</mirrorOf>
                <name>aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
            </mirror>
        
            <mirror>
                <id>repo1</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://repo1.maven.org/maven2/</url>
            </mirror>
        
            <mirror>
                <id>repo2</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://repo2.maven.org/maven2/</url>
            </mirror>
      </mirrors>
    
    阿里云maven镜像

    3.配置编译时的jdk版本,可以在这里配置全局,也可以根据项目配置 profiles 节点内

    <profile>
        <!-- 配置全局的jdk -->
            <id>jdk1.8</id>    
            <activation>   
                <activeByDefault>true</activeByDefault>    
                <jdk>1.8</jdk>   
            </activation>    
            <properties>   
                <maven.compiler.source>1.8</maven.compiler.source>    
                <maven.compiler.target>1.8</maven.compiler.target>    
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>   
            </properties> 
        </profile>
    
    全局的jdk版本配置

    eclipse 集成maven插件

    eclipse配置maven 配置全局参数

    新建maven项目

    新建maven项目 新建maven项目 新建maven项目 项目结构

    将项目转换成maven web 项目

    右键打开项目设置

    修改项目结构 生成web.xml 修改以后的项目结构

    但是现在这个不是一个标准的web项目,继续修改项目结构,将WebContent目录下的文件拷贝到main/webapp目录下面,删除WebContent目录,结构如下

    删除WebContent目录以后 删除WebContent 指定 webapp 目录 选择 webapp 选择 webapp 修改完成以后的目录结构 更新项目maven配置 提示更新 错误解决以后成为一个标准的web项目

    配置运行该项目

    1. 在webapp右键新建一个html 文件
    新建 html 文件,编写内容

    2.配置 tomcat

    配置运行项目 选择tomcat对应的版本 选择 tomcat 安装路径

    3.运行

    运行项目

    eclipse 集成 maven 构建 web 项目完成

    最后推荐一篇文章:在 idea 中如何使用 maven 构建项目

    https://yq.aliyun.com/articles/111053

    相关文章

      网友评论

        本文标题:eclipse 使用 maven 构建项目

        本文链接:https://www.haomeiwen.com/subject/ydpvextx.html