maven install and change the local warehouse location and associated myeclipse, create a maven project

 

maven configuration is divided into three parts, namely, to create a maven installation, local warehouse, associated development tools

Here is the associated development tools myeclipse, eclipse as applicable.

The following explanation of these three parts:

installation maven:

1. Download maven

2. The above maven download installation version is free, after decompression can be used directly.

3. Set Environment Variables

New MAVEN_HOME

Be careful not to locate the bin directory

Add% MAVEN% \ bin in the path variable

Click OK.

4. Verify that the installation was successful

Open the doc window:

win + R input cmd, enter the window in the doc mvn -v

Maven can view the current version number and jdk version number is configured successfully

 

Configuring local repository:

Local repository of configuration requires two parts, first lock the location of the local repository, which is next to tell maven local repository

1. When confirming the above will be automatically create a local warehouse in the user directory below, and tell maven This is a local warehouse

The warehouse in c drive, if you do not want to create the c drive below, you can create a local repository configured in the other disc, the following explains how to change the location of the local repository.

1. First, open the file in the conf file setting.xml under maven directory

Find probably around line 50 will find <localRepostiroty> tag is a comment, copy it down, paste it below the comment.

The location of the files you want to change the configuration of the local warehouse location, proposal to change the solid state drive, read and write speed.

2. Since the development of the project may need to get the jar package from the cloud repository, thus simultaneously change the cloud Ali cloud warehouse to warehouse

The following code into <mirrors> tag to

<mirror>

      <id>alimaven</id>

      <mirrorOf>central</mirrorOf> 

      <name>aliyun maven</name>

      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>     

</mirror>

3.在自己创建的本地仓库下,将maven中更改后的setting.xml文件复制到该仓库下

此时本地仓库的修改已经完成。

接下来将maven和本地仓库关联到开发工具myeclipse中,eclipse也可以。

首先将maven关联到开发工具中:

1.在window->preference下搜索maven

点击add

将maven的安装路径添加进入,注意不要到bin目录下,点击finish即可。

接下来需要将添加的maven的路径进行勾选,这样maven已经和myeclise关联。

 

下面需要将本地仓库和ide关联:

2.点击User Settings在Global Settings中选择自己maven安装路径下的settings.xml文件。

ide会自动搜索自己配置的本地仓库,如果没有自动搜素手动点击Update Settings即可

此时maven和ide就关联成功可以进行验证。

3.验证

window->show view->other

检索maven

注意后面的路径是否是自己的本地仓库

右键rebuild重新检索出现本地仓库中的信息

可以显示本地仓库中已经有的jar包,此时maven和ide就关联成功了。

接下来就是创建一个maven项目了

我们右键创建一个maven项目

点击后会有

红框中的属性不勾选的话,需要选择创建的项目类型

勾选的话就不用选择,出现如下图,可以在项目打包格式选择对应的项目类型,jar包就是Java项目,war包就是web项目,一般勾选

创建Java项目的话:

需要选择jar包格式

创建后的目录结构如下

创建web项目:

需要将打包格式更换为war包创建.

创建完成后目录结构会发生改变,在main目录下会多一个webapp目录,用来存放html或jsp文件

创建完成后会报错,是因为在main目录下的webapp目录下没有创建WEB-INF目录,以及web.xml,需要手动创建。

 

Guess you like

Origin www.cnblogs.com/mhm111/p/11345538.html