IDEA配置web项目、部署Tomcat、配置maven

原:https://blog.csdn.net/liang526011569/article/details/77101685

IDEA 配置web项目、配置maven三部分内容做一个总结。

一、配置web项目

1.配置Project Structure.

1.1 Project子选项

其中,第二个要选的language level:限定项目编译检查时最低要求的 JDK 特性。 现在假设我们有一个项目代码使用的 JDK 8 新特性:lambda 语法,但是 JDK 选择的却是 JDK 7,即使 language level 选择了 8 - Lambdas,type annotation etc.,也是没有多大意义的,一样会编译报错。

1.2 modules子选项(sources、 path、dependencies )

–sources标签页中配置项目结构 
(主要配置需编译的Java文件和配置文件) 

excluded是让.idea跳过执行
–Paths标签页中配置编译后文件输出路径

–Dependencies标签页中配置依赖关系

若没有maven,手动配置是要加上jdk和web-inf/lib的jar包

1.3在Artifacts项中设置项目的部署配置

二、maven
maven的用处:

不用我们自己去download jar包,而是通过maven提供的pom.xml去配置jar包信息,然后maven通过pom.xml配置信息和规则,通过maven的命令,最后从maven的中央jar包仓库download到你的maven本地仓库,最后被我们自动依赖到项目中从而被使用。

3.1,下载,安装,环境变量配置 
下载:http://maven.apache.org/download.cgi 
windows系统下载第二行第一个,zip格式的。

解压 

这里写图片描述
在系统变量中新建M2_HOME、在Path中添加 %M2_HOME%\bin

这里写图片描述

这里写图片描述
—在cmd命令行中输入mvn –version检测是否安装配置成功。

3.2 maven配置文件

maven需要配置的文件主要集中在pom.xml和settings.xml中. 
settings.xml在conf子目录下面,是Maven的基本配置,是一个包含了注释和例子的模板,你可以快速的修改它来达到你的要求。

  1. <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  3.   <localRepository/> 本地库的保存位置,也就是maven主要的jar保存位置
  4.   <interactiveMode/> Maven是否需要和用户交互以获得输入
  5.   <usePluginRegistry/>Maven是否需要使用plugin-registry.xml文件来管理插件版本
  6.   <offline/>表示Maven是否需要在离线模式下运行
  7.   <pluginGroups/>当我们使用某个插件,并且没有在命令行为其提供组织Id(groupId)的时候,Maven就会使用该列表
  8.   <servers/>配置服务端的一些设置
  9.   <mirrors/>  镜像库
  10.   <proxies/>  用来配置不同的代理
  11.   <profiles/> 根据环境参数来调整构建配置的列表
  12.   <activeProfiles/>手动激活profiles的列表
  13. </settings>


实际应用中,经常使用的是<localRepository>、<servers>、<mirrors>、<profiles>有限几个节点,其他节点使用默认值足够应对大部分的应用场景。我本机实例:

localrepository: 

这里写图片描述

mirror:公司镜像库 
mirritz

profiles:包含了激活(activation),仓库(repositories),插件仓库(pluginRepositories)和属性(properties)共四个子元素元素,repositories 和pluginRepositories 定义其他开发库和插件开发库。对于团队来说,肯定有自己的开发库。可以通过此配置来定义。

  1. <profiles>
  2.         <profile>
  3.             <id>dev</id>
  4.             <repositories>
  5.                 <repository>
  6.                     <id>nexus</id>
  7.                     <name>local private nexus</name>
  8.                     <url>http://nexus.it.taikang.com/content/groups/maven-public/</url>
  9.                     <releases>
  10.                         <enabled>true</enabled>
  11.                     </releases>
  12.                     <snapshots>
  13.                         <enabled>true</enabled>
  14.                     </snapshots>
  15.                 </repository>
  16.             </repositories>
  17.             <pluginRepositories>
  18.                 <pluginRepository>
  19.                     <id>nexus</id>
  20.                     <url>http://nexus.it.taikang.com/content/groups/maven-public/</url>
  21.                     <releases>
  22.                         <enabled>true</enabled>
  23.                     </releases>
  24.                     <snapshots>
  25.                         <enabled>true</enabled>
  26.                     </snapshots>
  27.                 </pluginRepository>
  28.             </pluginRepositories>
  29.         </profile>

3.3 IDE中设置maven 
—打开-File-Settings 

猜你喜欢

转载自blog.csdn.net/qqio10928/article/details/86063998