前言
我们知道最后的代码都是要运行在Linux系统中的,所以就需要在Linux中安装git,从而能够拉取代码,安装maven,从而能够进行项目的打包。
本篇博客以centos为例,介绍如何安装git,安装maven3.8,配置环境变量,并使用命令进行打包,然后运行jar包。
其他相关的maven和git的博客文章如下
目录
引出
1.介绍如何安装git;
2.安装maven3.8,配置环境变量;
3.使用命令进行打包,然后运行jar包
Linux安装git
安装git
java
yum install -y git
然后就可以进行代码的克隆
git clone https://gitee.com/pet365/java-gc-demo
安装maven
1.查找版本
https://maven.apache.org/download.cgi
2.下载和解压
java
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
java
tar -zxf apache-maven-3.8.8-bin.tar.gz
3.配置环境变量
java
/usr/local/software/maven/apache-maven-3.8.8
java
JAVA_HOME=/root/software/jdk/jdk1.8.0_371
CLASSPATH=.:$JAVA_HOME/lib
MAVEN_HOME=/usr/local/software/maven/apache-maven-3.8.8
PATH=$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH MAVEN_HOME PATH
是配置生效
java
source /etc/profile
输入mvn -version查看安装版本
4.配置阿里云仓库
xml
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
5.先清理后打包
java
mvn clean package
运行jar包
java
java -jar target/spring-gc-demo-1.0-SNAPSHOT.jar
总结
1.介绍如何安装git;
2.安装maven3.8,配置环境变量;
3.使用命令进行打包,然后运行jar包
附录:pom.xml文件
xml
<?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>com.tianju</groupId>
<artifactId>spring-gc-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot.version>2.3.8.RELEASE</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.8.RELEASE</version>
<executions>
<execution>
<goals>
<!--repackage 会从新打包应用,将所有的依赖项全部打包到一个jar包中-->
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.tianju.GcApp</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>