maven周期及项目中的应用:
周期如下:
1、default生命周期,部署项目(jar包的依赖管理)
2、clear生命周期,项目清理工作
3、site生命周期,处理项目中产生的文档信息
应用:
1、管理项目,添加jar包的依赖
2、可以把项目上传到git远程仓库,具体步骤如下
(1):ideal 配置好git
(2):在pom.xml中加入如下配置(注意放的位置)
(a):<scm>
(b):
现在基本配置好了。接下来是命令的执行:
mvn scm:checkin -Demessage="代码提交的说明" #这句命令是执行把代码提交到远程git仓库
mvn scm:update #代码更新,即把代码从远程仓库里面下载下来
下面是发布项目的配置
1:引入release 插件
2:引入tomcat7-maven-plugin插件
3:命令执行
mvn release:clean #发布前的清理
mvn release:prepare #发布版本
mvn release:rollback #回滚版本
下面是pom.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>hsbc.groupthree</groupId> <artifactId>ordersystem</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>ordersystem</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <repositories> <!-- ... possibly other repository elements ... --> <repository> <id>spring-milestone</id> <name>Spring Milestone Repository</name> <url>https://repo.spring.io/milestone</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!--<exclusions>--> <!--<exclusion>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-starter-tomcat</artifactId>--> <!--</exclusion>--> <!--</exclusions>--> </dependency> <!--部署到远程添加以下依赖,注释上面取消内嵌tomcat--> <!--<dependency>--> <!--<groupId>javax.servlet</groupId>--> <!--<artifactId>javax.servlet-api</artifactId>--> <!--<version>3.1.0</version>--> <!--<scope>provided</scope>--> <!--</dependency>--> <!--test class to ues mockmvc--> <dependency> <groupId>org.springframework.restdocs</groupId> <artifactId>spring-restdocs-mockmvc</artifactId> <scope>test</scope> </dependency> <!-- the start rley on test--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!--为了测试自己的先把security注释掉了,不然会拦截--> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <!--<version>5.0.7.RELEASE</version>--> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.7.0</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.24</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.12</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.11</version> </dependency> <!--the dependency of redis--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <!--the rely on lombok--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <!--to test start--> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>RELEASE</version> <scope>compile</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test-autoconfigure</artifactId> </dependency> <!-- end --> <!-- mock--> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> </dependency> <!--添加对excel的依赖--> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.9</version> </dependency> <!--下载的依赖--> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> </dependencies> <scm> <url>https://github.com/Liu15625177108/NewOrderSystem</url> <!--把代码pull 下来的链接--> <connection>scm:git:https://github.com/Liu15625177108/NewOrderSystem</connection> <!--把代码提交上去的链接--> <developerConnection>scm:git:https://github.com/Liu15625177108/NewOrderSystem</developerConnection> </scm> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin>
<!--scm插件的引入--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-plugin</artifactId> <version>1.9.5</version> <configuration> <connectionType>developerConnection</connectionType> <username>CHENL0</username> <password>79513Aa123</password> </configuration> </plugin>
<!--版本发布的release 插件--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.5.3</version> <configuration> <username>CHENL0</username> <password>79513Aa123</password> <tagBase>${project.artifactId}-${project.version}</tagBase> <goals>-f pom.xml deploy</goals> </configuration> </plugin>
<!--版本发布需要用到的tomcat插件--> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <url>http://123.207.22.215:8080/manager/text</url> <server>admin</server> <username>admin</username> <password>123456</password> <update>true</update> <!--<path>/webapps</path>--> </configuration> </plugin> </plugins> </build> </project>