How Maven configures Ali mirroring and installation steps

Configure Ali mirroring

For details, see below, there are detailed steps to
introduce Ali mirroring

 <!-- 中央仓库在中国的镜像 -->
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>

Installation environment preparation

  • jdk1.8 and above
  • maven3.3.9 installation tool
  • Tomcat server

maven installation steps

1. Maven officially downloads the maven zip file ( download path of version 3.3.9 ) and
clicks to automatically download the zip file Insert picture description here
2. Unzip the downloaded file to the hard disk (my unzip path: E:\maven)
After unzipping:
Insert picture description here
3. Configuration Environment variables MAVEN_HOME and PATH

MAVEN_HOME
Insert picture description here
PATH
Insert picture description here
test whether the installation is successful:
enter mvn -v in the black window;
Insert picture description here

Configure the central warehouse

1. Set up a local central warehouse.
After we successfully downloaded, maven automatically created a local maven warehouse on the c drive (C:\Users\DELL.m2\repository). But this path is not easy to find, and it is on the c drive, so we have to create a local maven warehouse elsewhere and overwrite the previous warehouse path.
Insert picture description overlay here
2. Overwrite the previous local warehouse path and import the Ali image.
Open the maven file,
apache-maven-3.3.9——conf——settings.xml (copy a backup first)——find path/to/local/repo——in Create a new local warehouse path later-introduce Ali mirroring (when we support maven later, we need to connect to a foreign website to download the plug-in, the speed will be very slow, Ali mirroring can solve it)

Create a copy:
Create a copy
overwrite the maven path

 <localRepository>E:\maven\maven_repository</localRepository>

Override maven path
Introduce Ali mirror

 <!-- 中央仓库在中国的镜像 -->
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>

Introduce Ali mirror

Configure Maven in IDEA

  1. Introduce maven and configuration files and local warehouse path.
    Step 1: Select setting
    Insert picture description here
    Step 2: Configure maven
    Insert picture description here
    Step 3: Configure Runner
    property value under Maven : -DarchetypeCatalog=internal
    Reason for configuring this property: When we download the maven plugin, we need to download it online. If there is no such attribute, we have to download it from the Internet every time we create a new project. With this attribute, it will be saved in the local warehouse and can be used directly next time.
    Insert picture description here
    Step 4: Open the other setting, select setting for new Project and
    repeat the first three steps (after this configuration, when you create a new project, you will use your settings by default. The first three steps are configured for the current project)
    Insert picture description here

Create a maven web project

The first step: select the jdk version number and introduce the Maven skeleton prepared for us by related IDEA.
Note: When using the skeleton, check it.
Insert picture description here
Step 2: Start the project name, and then the next
Insert picture description here
step. Step 3: Configure the path.
If you have configured the settings in IDEA before, then this step will automatically generate the path you configured in IDEA. But it is best that you check it first.
Insert picture description here
Step 4: Analyze related information
Insert picture description here
Insert picture description here
Step 5: Improve related packages
We know that maven provides some specifications for our directory structure.
There are java packages and resource packages. And test packages, etc. The plug-in we introduced does not have these, we need to build it manually.
Insert picture description here
Step 6: We set up the created package as a source file, so that we are constrained and can only write fixed content in a fixed place. For example, you can only write java related content under java, but not jsp related content. This standardizes our operations.
Insert picture description here
Step 7: We have completed the related maven configuration. Now you can write a formal project

The introduction of Tomcat server in Maven

The first step: introduction
Insert picture description here

Insert picture description here

Write project

Step 1: Create a servlet package and create a servlet interface (SelectDemo_01)Insert picture description here
Insert picture description here

Step 2: First, we will jump to the web.xml page to let us configure the relevant path. Secondly, we will find that there will be a packet import error in our interface,
prompting us to configure the path. Insert picture description here
Solution:
Insert picture description here

Guide package error:
We know that after we use maven, we no longer need to guide package, just introduce relevant content directly on the network. Here we need to introduce servlet.
Insert picture description here
Step 3: Introduce servlet and jsp related configuration files

Import address (servlet):
https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api/3.1.0
Import address (jsp):
https://mvnrepository.com/artifact/javax.servlet/jsp -api/2.0
In fact, both of them are in the central maven warehouse. After obtaining the other ones, go directly to the warehouse to find
Insert picture description here
jsp in the same way.

pom.xml file

Insert picture description here
At this point, we found that the problem of guiding the package in the servlet has disappeared.
Insert picture description here
At this time, the package prefix of javax.servlet can be deleted.

The fourth step: write related content: in the
index.jsp
Insert picture description here
interface; the
Insert picture description here
fifth step: run the
index.jsp
Insert picture description here
interface:
Insert picture description here

to sum up

In the maven configuration process, if the system is not configured, it is easy to make some small errors. So be careful when configuring, every step is important

Guess you like

Origin blog.csdn.net/zhang19903848257/article/details/107923791