git和maven的理解和学习

git和maven的理解和学习

git

1 git的工作机制
在这里插入图片描述
2 git的基本命令
在这里插入图片描述
在这里插入图片描述
3 git的忽略文件的配置模板
步骤1 在C:\Users\likun目录下新建git.ignore文件 如下
步骤2 配置在C:\Users\likun 目录下的.gitconfig中 如下

# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see 
http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.classpath
.project
.settings
target
.idea
*.iml
[user]
	name = likun
	email = 1026352280@qq.com
[core]
excludesfile = C:/Users/likun/git.ignore

4 学习理解
理解1 :保持良好的提交代码习惯,就按照这个顺序去做

1 拿到代码先去拉代码,保证自己想在的代码是最新的。
2 开始cv代码  add加到暂存区 commit提交到本地库中 
3 在push之前,一定要再一次的拉取一下代码,防止在你写代码的
过程中可能会有人提交,这次可能会产生冲突,解决冲突之后再去进行push.  

理解2

分支的概念在你的本地或者远程gitlab中都有存在,所以你可以在你的本地
建立各种的分支。但是一定要记得在idea中提交的时候push的时候看你是提
交的哪个分支,并且提交到远程的又是哪个分支。千万注意!

maven

1 maven的生命周期

1 mvn clean清理(会删除原来编译和测试的目录,即 target 目录,但是已经
install 到仓库里的包不会删除)
2 mvn compile 编译主程序(会在当前目录下生成一个 target,里边存放编译主
程序之后生成的字节码文件)
4 mvn test-compile 编译测试程序(会在当前目录下生成一个 target,里边存放
编译测试程序之后生成的字节码文件)
5 mvn test 测试(会生成一个目录surefire-reports,保存测试结果)
6 mvn package打包主程序(会编译、编译测试、测试、并且按照 pom.xml 配置把主程
序打包生成 jar 包或者 war 包)
7 mvn install 安装主程序(会把本工程打包,并且按照本工程的坐标保存到本地
仓库中)
8 mvn deploy 部署主程序(会把本工程打包,按照本工程的坐标保存到本地库
中,并且还会保存到私服仓库中。还会自动把项目部署到 web 容器中)

2 pom文件的事例
父模块

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>likun</groupId>
    <artifactId>com.cn</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <!--子工程 进行聚合-->

    <modules>
        <module>../module_01</module>
    </modules>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
</project>

子模块

<?xml version="1.0" encoding="UTF-8"?>

<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>

  <groupId>likun</groupId>
  <artifactId>com.it</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <!--子工程声明父工程-->
  <parent>
    <groupId>likun</groupId>
    <artifactId>com.cn</artifactId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../parent/pom.xml</relativePath>
  </parent>
  

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

   <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.1</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <finalName>com.it</finalName>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.2.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

注意点:

1 打包方式有jar war pom ,默认为jar
java工程为jar   
javaweb项目为war  (打包之后把打好的war文件直接放在)tomcat的webapps目录下
就可以,启动tomcat之后就会自动解压部署,访问即可。
父工程的打包方式为pom
2 在没有使用聚合之前,子模块之后在父模块打包之后才可以进行打包,否则会失败
在进行聚合之后,在父工程可以一键进行打包,会将包含的所有模块直接全部打包。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值