Java Novice Learning Guide [day47] --- Know Maven, learn programming tools

One, the understanding and configuration of Maven

1. Know Maven

Is a project management tool

Features:

It is a software project management tool that has a pom.xml configuration file that can manage project construction, reports, and documents through a small piece of description information.

Advantage:

① Automatic construction: Using Maven can complete many corresponding functions for us: clean up the code, automatically compile, complete the test, generate site reports, package (jar, war), and deploy the project. (Maven provides us with a lot of ready-to-use functions)

② Automatic package guide: Solve the cumbersome introduction of jar packages before, and many jar packages still have dependent packages. Maven perfectly solves this problem. We only need to import the function package, and it will automatically import the corresponding dependent package for us.

③. Contract programming: stipulates the basic structure of the project, so that the project can increase maintainability, and the development after the structure is written is more convenient, removes the personalized code structure, and enhances cooperation

2. Installation and configuration of Maven

①, install JDK

Maven is a Java-based tool, so the first thing to do is to install the JDK.

  • Download from official website to decompress

  • Configure environment variables

  • Verify installationjava -version

②, install Maven

  • Download and unzip from official website
  • Configure environment variables
  • Check if the configuration is successfulmvn -v

1606217901647

1606217921704

③. Configure the local warehouse (the local warehouse is configured on the non-system disk )

Maven will automatically add the corresponding jar package to the project, and this jar package will first be searched in the local warehouse . If it is not found in the local warehouse, it will go to the central warehouse (on the network) to download it.

  • Move the settings.xml file

    Find the settings.xml from apache-maven-3.3.9\conf and put it in the user's root path C:\Users\53187.m2 ( mvnthis folder will be created automatically after running the command in the DOS window )

  • Prepare the local warehouse

    D:\OpenSource\repository (do not include Chinese, spaces, or special symbols in the path)

  • Configuration file setting path to local warehouse

    The settings.xml file under the user's root path

    increase<localRepository>D:/OpenSource/repository</localRepository>

3. Common commands for testing Maven

mvn compile----->Compile the project

mvn clean ----->Clear compiled content

mvn clean compile----->Clear first and then compile

mvn clean package----->Clear first and then pack

mvn install----->Jar the current project

mvn package -Dmaven.test.skip=true----->Skip test packaging

------------------------------------------The above is more important---- -------------------------------------------------- -------------------

mvn test----->Run test

mvn source:jar----->Open source jar package

mvn site----->Generate project documentation

mvn eclipse:eclipse----->Build a project that eclipse can recognize

4. Maven guide package

①, understand the basic configuration of pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<!-- 组id:包名 -->
	<groupId>cn.itsource.maven</groupId>
	<!-- 模块名:和项目名一致 -->
	<artifactId>Hello</artifactId>
	<!-- 版本号 -->
	<!-- SNAPSHOT快照,不稳定,随时都在修改bug -->
	<!-- RELEASE 释放,稳定版本 -->
	<version>0.0.1-SNAPSHOT</version>
	<!-- 项目名 -->
	<name>hello</name>
	<!-- jar文件依赖,管理依赖 -->
	<dependencies>
        <!-- 依赖的jar包 -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.9</version>
			<!-- 只能在测试里面使用src/test/java -->
			<scope>test</scope>
		</dependency>
	</dependencies>
</project>

②, Internet search coordinates

Website: http://mvnrepository.com/

  • Search directly

1606231765237

  • Choose one of your needs from the search results

1606231787723

  • Choose a corresponding version

  • Just copy the data over

1606231844898

③, Maven plug-in

<!-- 全局jdk配置,settings.xml -->
    <profile>  
        <id>jdk18</id>  
        <activation>  
            <activeByDefault>true</activeByDefault>  
            <jdk>1.8</jdk>  
        </activation>  
        <properties>  
            <maven.compiler.source>1.8</maven.compiler.source>  
            <maven.compiler.target>1.8</maven.compiler.target>  
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>  
        </properties>   
    </profile>

5. Understanding of the warehouse

① There are two types of Maven warehouses

**Local warehouse: **Explanation: it is the place where the jar package of your computer is located

Default path: ~/.m2/repository/

Note: Each user has only one local warehouse

Remote warehouse:

Central warehouse (http://repo1.maven.org/maven2)

Mirror warehouse (used to replace the central warehouse, the speed is generally faster than the central warehouse: Ali, Baidu, Tencent, CSDN)

Private server (created by some companies, and can be used under the internal network)

②, configure the mirror node

In the mirrors node in the settings.xml file of maven, add the following sub-nodes:

<mirror>  
    <id>nexus-aliyun</id>  
    <mirrorOf>central</mirrorOf>    
    <name>Nexus aliyun</name>  
<url>http://maven.aliyun.com/nexus/content/groups/public</url>  
</mirror> 

Two, IDEA

One of the best Java development environment

1. Install Intellij IDEA

Fool-style installation, only the following configuration needs attention

img

2、PJ

img

3. Create a Maven project

Go to the new location to choose the JDK you installed

img

image-20201228181553963

4. Run the Maven project in Tomcat

  • Run->Edit Configurations

  • Click on default, select tomcatServer, select local

  • Click configure under the server tab to configure local tomcat

1606233510320

  • Choose Artifact

img

Step file for generating pss

img

  • After configuration, click the + sign in the upper left corner, select tomcat server->local, click the + sign under the deployMent tab, and add the project to be published

3. UML (Unified Modeling Language)

1. What is UML

Unified Modeling Language (UML) is also known as Unified Modeling Language (graphics) or Standard Modeling Language

UML: Draw (use case diagram, class diagram, flowchart) -> analysis system -> modeling

3. Learning UML is to understand three kinds of diagrams

①, use case diagram: used to describe permissions

img

②, class diagram: description of the class

1606234007490

img

③, flow chart

img

Guess you like

Origin blog.csdn.net/WLK0423/article/details/114223017