Maven project of SSH Framework

Foreword: I shared with you the online bookstore project written using MVC framework. Among them, the most important is the production of MVC framework (xml, reflection, custom tags, general paging, custom MVC, easyui). Today we will share a new thing called Maven integrated ssh framework, mainly to introduce Maven.

1, Maven learning objectives:

        1. Experience the convenience brought by Kaiyuan's excellent framework

        2. Knowledge verification of and custom MVC framework

        3. Mode transformation of development mode

2, Maven definition:

        1. Definition: Maven is a tool dedicated to building and managing java related projects.

                        The concept may be a little abstract. Next, use specific examples to help you understand. When doing the online bookstore project, we need to import many jar packages. Among them, the disadvantages are as follows:

                        1. jar packages need to be found one by one, which is very troublesome

                        2. There is a conflict between jar packages, which will lead to an error

                        So the Maven project came into being at this time.

3, How Maven works:

        I will use a picture to explain Maven's working principle:

  I will explain the principle in four steps: (the red font below is the noun to understand)

                1. If the project wants to use the jar package, first go to the maven local warehouse (find the jar package through the coordinates of pom: project object model and project object model) to find the target jar package, which will be automatically imported into the project and used

                2. If there is no target jar package in the local warehouse, the target jar package will be found in the Alibaba private server warehouse. If it is found, it will be automatically downloaded to the local warehouse and imported into the project for use

                3. If there is no target jar package in the Alibaba cloud warehouse (server), it will be downloaded from the foreign maven central warehouse and finally to the local warehouse

Note: if an error is reported after downloading from a foreign mave central warehouse, it is a code problem

4, How do I use Maven


                  1. Unzip folder

Put the compressed folder on a disk and decompress it (Note: the name of the folder should be in English, followed by the -- bin folder, as long as the innermost maven folder)


After decompression, don't use the two folders with -- bin in the middle, just the last folder. (method: copy the last folder, create a new folder on the disk, paste the last folder, and put the original compressed package in it)

                  2. Configure environment variables:

                        Step 1: open computer properties, click Advanced system settings, click environment variables,

                        Step 2: click Edit to configure Maven first_ Home, the variable value is the path from the previously extracted folder to the new folder,

                         Step 3: then find the path variable in the system variable, edit it, create a new one, and write% MAVEN_HOME%\bin

                          Step 4: verify. After configuration, mark mvn -version in cmd to verify whether it is configured (the figure shows that the configuration is successful)  

                  three  , Configure local warehouse and private warehouse (private warehouse here refers to Alibaba cloud warehouse)

                        1. Configure the local warehouse: open the newly unzipped folder, click it, click the conf directory, click settings.xml to change it, click it, press ctrl+F to query the local, find the local and change it to the figure below:

                          2. Configure the image warehouse: search for a mirror in settings.xml to make changes: change the above mirror to the following one  

In this way, the local warehouse and Alibaba cloud warehouse are configured.

5: What problems have been solved:

Using maven solves the problem that you don't have to import jar packages manually.

6, Practical operation: run maven project

          1. Enter eclipse to configure maven, click windows - > preferences, then search maven, click installations in maven, click Add to find your Maven folder, and then add the folder.

          2. Under the same panel, click User Settings, and then add settings (local warehouse) under conf file under maven folder

          3. After creating a new project, an error will be reported (very normal). First, delete the index file under webapp in main under src. I deleted it at that time.

          4. Then, right-click the newly created project, click Properties, find Project Facets, find java, change the version from 1.5 to 1.8, then use and close it, and then repeat the above operations, find the Dymamic web module, and change the version from 2.3 to 3.1. Note: cancel the check of Dymamic web module, then run and close it, Then enter the interface and check it. A line of English sentence will appear below. Click to change webcontent to webapp.

            5. Change the content in web.xml: change the code from to the following:

<web-app xmlns=""
  <display-name>Archetype Created Web Application</display-name>

            6. Change the content in pom.xml: to change the version from 3.8.0 to 4.0.0:

                  Search the website in the browser. After entering, search for servlets in the search box and click Java Servlet API 4.0.0  

Then click maven to copy the code in maven to pom.xml

  After pasting it, the corresponding file will be downloaded. It takes a few minutes.

            7. After completing the above operations, create a new package in the / src/main/java directory and then create a class:

  After that, the results will appear after running with tomcat. The printing statement indicates that the project is successfully run with maven  

            8. Note:

                  1. When contacting maven project, the network must be connected, and the network quality is good.

                  2. MAVEN projects have no dependencies by default

            9. Import complete dependencies: (write the following code to the pop.xml file and wait for the download to complete)


    <!--add to jar Package dependency-->













Summary: Maven simply manages jar packages. Compared with importing jars manually before, Maven is easier. In the process of learning maven, the most important thing is to understand the principle of Maven. The principle is very important. After understanding the principle thoroughly, Maven will naturally learn it well.

Tags: Maven mvc EasyUI

Posted on Tue, 12 Oct 2021 16:51:19 -0400 by may27