maven mvn 命令行 編譯打包

* 配置好jdkhtml

 

* 下載安裝maven  web

http://maven.apache.org/download.cgi數據庫

apache-maven-3.3.3-bin.zipapache

 

* 解壓到G:\apache-maven-3.5.3-binbootstrap

 

* 添加環境變量windows

** 添加 M2_HOME 和 MAVEN_HOME 環境變量到 Windows 環境變量,並將其指向你的 Maven 文件夾瀏覽器

** Path環境變量添加 %M2_HOME%\bintomcat

 

* 查看mvn版本bash

1
mvn -version

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T03:49:05+08:00)
Maven home: G:\apache-maven-3.5.3-bin\bin\..
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_131\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"app

 

* mvn編譯打包

** 先把命令行切換到Maven項目的根目錄

1
cd  G:\eclipse-workspace\platform\enso-admin

** 編譯

1
mvn clean compile

  output:

  mvn clean compile

 ** 打包

1
mvn clean package

  output:

  mvn clean package

 

  output...

 ** 部署

 # 根據上一步的輸出 把 複製出來

1
2
3
copy G:\eclipse-workspace\platform\enso-admin\target\enso-admin-1.0.war G:\apache-tomcat-7.0.88-windows-x64\webapps\enso-admin.war
 
G:\apache-tomcat-7.0.88-windows-x64\bin\startup.bat

  

  須要先設置環境變量 CATALINA_HOME

The CATALINA_HOME environment variable is not defined correctly
This environment variable is needed to run this program

1
set  CATALINA_HOME=G:\apache-tomcat-7.0.88-windows-x64

  再試啓動tomcat

1
%CATALINA_HOME%\bin\startup.bat

  

Using CATALINA_BASE: "G:\apache-tomcat-7.0.88-windows-x64"
Using CATALINA_HOME: "G:\apache-tomcat-7.0.88-windows-x64"
Using CATALINA_TMPDIR: "G:\apache-tomcat-7.0.88-windows-x64\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_131"
Using CLASSPATH: "G:\apache-tomcat-7.0.88-windows-x64\bin\bootstrap.jar;G:\apache-tomcat-7.0.88-windows-x64\bin\tomcat-juli.jar"

 ** 配置不對 先停掉tomcat服務

1
2
%CATALINA_HOME%\bin\ shutdown .bat
del %CATALINA_HOME%\webapps\enso-admin-1.0.war

  

** 修改配置

1
2
@doskey n2= "C:\Program Files (x86)\Notepad++\notepad++.exe"  $*
n2 %CATALINA_HOME%\conf\server.xml

 

在server.xml文件的 </Host> 閉合標籤前面添加一行

1
< Context  docBase="enso-admin" path="/" reloadable="true" source="org.eclipse.jst.jee.server:enso-admin"/>

 

** 再啓動

1
%CATALINA_HOME%\bin\startup.bat

  

** 數據庫鏈接失敗

1
2
set  PROJECT=enso-admin
n2 %CATALINA_HOME%\webapps\%PROJECT%\WEB-INF\classes\jdbc.properties

  

** 瀏覽器訪問

先試試 http://localhost:8080/enso-admin

而後重啓tomcat

1
2
%CATALINA_HOME%\bin\ shutdown .bat
%CATALINA_HOME%\bin\startup.bat

再訪問 http://localhost:8080/

相關文章
相關標籤/搜索