1.查看環境變量的命令:spring
vim ~/.bash_profile
2.查看包含隱藏文件的文件列表apache
ls -al
3.更改mvn路徑vim
export M3_HOME=/Users/guanguan/apache-maven-3.3.9 export PATH=$PATH:$M3_HOME/bin source .bash_profile
而後執行mvn -version查看環境變量是否生效bash
➜ ~ mvn -version Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00) Maven home: /Users/guanguan/apache-maven-3.3.9 Java version: 1.8.0_92, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac" ➜ ~
4.執行mvn clean package命令maven
➜ springCloud mvn clean package [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for com.test.springCloud:springCloud:jar:1.0-SNAPSHOT [WARNING] 'parent.relativePath' of POM com.test.springCloud:springCloud:1.0-SNAPSHOT (/Users/guanguan/study/springCloud/pom.xml) points at com.test:myShiro instead of org.springframework.boot:spring-boot-starter-parent, please verify your project structure @ line 11, column 13 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building springCloud 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ springCloud --- [INFO] Deleting /Users/guanguan/study/springCloud/target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ springCloud --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 3 resources [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springCloud --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to /Users/guanguan/study/springCloud/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ springCloud --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/guanguan/study/springCloud/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ springCloud --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ springCloud --- [INFO] No tests to run. [INFO] [INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ springCloud --- [INFO] Building jar: /Users/guanguan/study/springCloud/target/springCloud-1.0-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.080 s [INFO] Finished at: 2017-10-23T15:02:22+08:00 [INFO] Final Memory: 33M/282M [INFO] ------------------------------------------------------------------------ ➜ springCloud
執行順序以下:spring-boot
一、使用清理插件:maven-clean-plugin:2.5執行清理刪除已有target目錄(版本2.5);測試
二、使用資源插件:maven-resources-plugin:2.6執行資源文件的處理(版本2.6);ui
三、使用編譯插件:maven-compiler-plugin:3.1編譯全部源文件生成class文件至target\classes目錄下(版本3.1);this
四、使用資源插件:maven-resources-plugin:2.6執行測試資源文件的處理(版本2.6);插件
五、使用編譯插件:maven-compiler-plugin:3.1編譯測試目錄下的全部源代碼(版本3.1);
六、使用插件:maven-surefire-plugin:2.12運行測試用例(版本2.12);
七、使用插件:maven-jar-plugin:2.4對編譯後生成的文件進行打包,包名稱默認爲:artifactId-version,好比本例生成的jar文件:springCloud-1.0-SNAPSHOT,包文件保存在target目錄下(這個生成的包不能在命令行中直接執行,由於咱們尚未入口類配置到Manifest資源配置文件中去,後續會闡述)。
備註:
無論是compile、package仍是install等前三個步驟都是必不可少的。