Article Directory
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
2. Unzip the downloaded file to the hard disk (my unzip path: E:\maven)
After unzipping:
3. Configuration Environment variables MAVEN_HOME and PATH
MAVEN_HOME
PATH
test whether the installation is successful:
enter mvn -v in the black window;
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.
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:
overwrite the maven path
<localRepository>E:\maven\maven_repository</localRepository>
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>
Configure Maven in IDEA
- Introduce maven and configuration files and local warehouse path.
Step 1: Select setting
Step 2: Configure maven
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.
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)
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.
Step 2: Start the project name, and then the next
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.
Step 4: Analyze related information
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.
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.
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
Write project
Step 1: Create a servlet package and create a servlet interface (SelectDemo_01)
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.
Solution:
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.
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
jsp in the same way.
pom.xml file
At this point, we found that the problem of guiding the package in the servlet has disappeared.
At this time, the package prefix of javax.servlet can be deleted.
The fourth step: write related content: in the
index.jsp
interface; the
fifth step: run the
index.jsp
interface:
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