注:圖片如果損壞,點擊文章鏈接:https://www.toutiao.com/i6809285459722633736/
創建工程
使用maven工程
勾選,然後下一步
填寫基本信息
注意改一下編碼和JDK
pom配置(附在文檔後面)
引入jar(這個包一直不能下載,所以另外導入)
創建運行類
編寫代碼
繼續編寫
主方法測試下,先在windows上測試完成後,再放到linux上執行看下,本地測試就不測試了,直接打包
打包,執行install
因爲我們引入了別的包,所以我們的包會比別的包大一些,不要弄錯了
就是這個包
拷貝pom時候,注意更改自己的主類
改名字上傳
然後執行打包語句
java -jar zipexe.jar /usr/local/pimages /data/1.tar.gz
編寫一個腳本,方便下次執行
執行結果
<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>