編寫java程序壓縮Linux本地目錄

注:圖片如果損壞,點擊文章鏈接:https://www.toutiao.com/i6809285459722633736/

創建工程

java壓縮打包本地目錄然後編寫腳本執行

 

使用maven工程

java壓縮打包本地目錄然後編寫腳本執行

 

勾選,然後下一步

java壓縮打包本地目錄然後編寫腳本執行

 

填寫基本信息

java壓縮打包本地目錄然後編寫腳本執行

 

注意改一下編碼和JDK

java壓縮打包本地目錄然後編寫腳本執行

 

pom配置(附在文檔後面)

java壓縮打包本地目錄然後編寫腳本執行

 

引入jar(這個包一直不能下載,所以另外導入)

java壓縮打包本地目錄然後編寫腳本執行

 

創建運行類

java壓縮打包本地目錄然後編寫腳本執行

 

編寫代碼

java壓縮打包本地目錄然後編寫腳本執行

 

java壓縮打包本地目錄然後編寫腳本執行

 

繼續編寫

java壓縮打包本地目錄然後編寫腳本執行

 

java壓縮打包本地目錄然後編寫腳本執行

 

主方法測試下,先在windows上測試完成後,再放到linux上執行看下,本地測試就不測試了,直接打包

java壓縮打包本地目錄然後編寫腳本執行

 

打包,執行install

java壓縮打包本地目錄然後編寫腳本執行

 

因爲我們引入了別的包,所以我們的包會比別的包大一些,不要弄錯了

java壓縮打包本地目錄然後編寫腳本執行

 

就是這個包

java壓縮打包本地目錄然後編寫腳本執行

 

拷貝pom時候,注意更改自己的主類

java壓縮打包本地目錄然後編寫腳本執行

 

改名字上傳

java壓縮打包本地目錄然後編寫腳本執行

 

然後執行打包語句

java -jar zipexe.jar /usr/local/pimages /data/1.tar.gz

java壓縮打包本地目錄然後編寫腳本執行

 

編寫一個腳本,方便下次執行

java壓縮打包本地目錄然後編寫腳本執行

 

執行結果

java壓縮打包本地目錄然後編寫腳本執行

 

複製代碼

<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.xlgl.wzy</groupId>
<artifactId>mail</artifactId>
<version>0.0.1-SNAPSHOT</version>
 
<dependencies>
 
<dependency> 
<groupId>commonsIO</groupId>   <!--自定義-->
<artifactId>commonsIO</artifactId>  <!--自定義-->
<version>2.5.0</version>   <!--自定義-->
<scope>system</scope>  <!--system,類似provided,需要顯式提供依賴的jar以後,Maven就不會在Repository中查找它-->
<systemPath>${pom.basedir}/jar/commonsIO-2.5.0.jar</systemPath>  <!--項目根目錄下的lib文件夾下-->
</dependency>
 
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
 
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.8</version>
</dependency>
 
 
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.5</version>
</dependency>
 
<!--郵件發送-->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
</dependencies>
 
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.xlgl.wzy.zip.ZipExecute</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
 
 

複製代碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章