Maven建立Web應用程式專案
1.從Maven模板建立Web專案,輸入如下命令:
mvn archetype:generate -DgroupId=com.yiibai -DartifactId=CounterWebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
C:\software\develop\workplace>mvn archetype:generate -DgroupId=com.test -Dartifa
ctId=testWeb -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
...
2225: remote -> xyz.luan.generator:xyz-generator (-)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co
ntains): 1235:
Choose org.apache.maven.archetypes:maven-archetype-quickstart version:
1: 1.0-alpha-1
2: 1.0-alpha-2
3: 1.0-alpha-3
4: 1.0-alpha-4
5: 1.0
6: 1.1
7: 1.3
Choose a number: 7:
[INFO] Using property: groupId = com.test
Define value for property 'artifactId':
Define value for property 'version' 1.0-SNAPSHOT: :
[INFO] Using property: package = com.test
[WARNING] Archetype is not fully configured
[INFO] Using property: groupId = com.test
Define value for property 'artifactId':
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = com.test
[WARNING] Archetype is not fully configured
[INFO] Using property: groupId = com.test
Define value for property 'artifactId':
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = com.test
[WARNING] Archetype is not fully configured
[INFO] Using property: groupId = com.test
Define value for property 'artifactId': testWeb
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = com.test
Confirm properties configuration:
groupId: com.test
artifactId: testWeb
version: 1.0-SNAPSHOT
package: com.test
Y: :
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Archetype: maven-arc
hetype-quickstart:1.3
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: com.test
[INFO] Parameter: artifactId, Value: testWeb
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.test
[INFO] Parameter: packageInPathFormat, Value: com/test
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.test
[INFO] Parameter: groupId, Value: com.test
[INFO] Parameter: artifactId, Value: testWeb
[INFO] Project created from Archetype in dir: C:\software\develop\workplace\test
Web
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:16 min
[INFO] Finished at: 2018-09-12T15:03:26+08:00
[INFO] Final Memory: 14M/102M
[INFO] ------------------------------------------------------------------------
2.要匯入這個專案到Eclipse中,需要生成一些 Eclipse 專案的配置檔案,在命令列中輸入:
mvn eclipse:eclipse -Dwtpversion=2.0
C:\software\develop\workplace\testWeb>mvn eclipse:eclipse -Dwtpversion=2.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building testWeb 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-eclipse-plugin:2.10:eclipse (default-cli) > generate-resources
@ testWeb >>>
[INFO]
[INFO] <<< maven-eclipse-plugin:2.10:eclipse (default-cli) < generate-resources
@ testWeb <<<
[INFO]
[INFO] --- maven-eclipse-plugin:2.10:eclipse (default-cli) @ testWeb ---
[INFO] Adding support for WTP version 2.0.
[INFO] Using Eclipse Workspace: C:\software\develop\workplace
[INFO] no substring wtp server match.
[INFO] Using as WTP server : Apache Tomcat v7.0
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAIN
ER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre8
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "testWeb" to C:\software\develop\workplace\test
Web.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.059 s
[INFO] Finished at: 2018-09-12T15:10:18+08:00
[INFO] Final Memory: 13M/184M
[INFO] ------------------------------------------------------------------------
注意,此選項 -Dwtpversion=2.0 告訴 Maven 將專案轉換到 Eclipse 的 Web 專案(WAR),而不是預設的Java專案(JAR)。
3.將專案打包,預設是jar包
C:\software\develop\workplace\testWeb>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building testWeb 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ testWeb
---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\software\develop\workplace\testWeb
\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ testWeb ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\software\develop\workplace\testWeb\target\c
lasses
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @
testWeb ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\software\develop\workplace\testWeb
\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ testW
eb ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\software\develop\workplace\testWeb\target\t
est-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ testWeb ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.test.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 s -
in com.test.AppTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ testWeb ---
[INFO] Building jar: C:\software\develop\workplace\testWeb\target\testWeb-1.0-SN
APSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.451 s
[INFO] Finished at: 2018-09-12T15:30:03+08:00
[INFO] Final Memory: 16M/88M
[INFO] ------------------------------------------------------------------------
4.清空target打包後的目錄檔案
C:\software\develop\workplace\testWeb>mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building testWeb 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ testWeb ---
[INFO] Deleting C:\software\develop\workplace\testWeb\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.324 s
[INFO] Finished at: 2018-09-12T15:29:54+08:00
[INFO] Final Memory: 6M/164M
[INFO] ------------------------------------------------------------------------
相關文章
- maven 建立web專案MavenWeb
- 如何用Maven建立web專案MavenWeb
- Maven通過命令建立web專案MavenWeb
- 如何建立+管理maven、匯入web專案、xmlMavenWebXML
- IDEA--Maven建立WEB分模組專案IdeaMavenWeb
- 用maven建立專案及maven常用命令Maven
- Maven配置-使用Maven建立WEB專案支援Tomcat目錄部署MavenWebTomcat
- Maven Web 應用MavenWeb
- Gradle入門(6):建立Web應用專案GradleWeb
- 原創一看便知、Maven建立web專案MavenWeb
- 建立Maven模板專案Maven
- Maven建立Java專案MavenJava
- IntelliJ IDEA中建立Web聚合專案(Maven多模組專案)IntelliJIdeaWebMaven
- maven學習總結(七)——eclipse中使用Maven建立Web專案MavenEclipseWeb
- Python,Django建立web專案project和應用appPythonDjangoWebProjectAPP
- 建立Maven專案出錯Maven
- Maven--搭建Web專案MavenWeb
- Maven Web專案構建MavenWeb
- Gradle入門:建立 Spring Boot Web 應用專案GradleSpring BootWeb
- 使用IntelliJ IDEA 15和Maven建立Java Web專案IntelliJIdeaMavenJavaWeb
- maven 專案的建立入門Maven
- maven專案增加web.xmlMavenWebXML
- mvn 建立java專案 web專案JavaWeb
- Maven+myeclipse 建立聚合專案MavenEclipse
- 使用maven2快速建立專案Maven
- idea建立web專案IdeaWeb
- 建立Maven專案出錯 pom出錯Maven
- Springboot建立maven多模組專案Spring BootMaven
- Maven建立專案遇到導包錯誤:Maven
- Electron桌面應用程式從建立專案、啟動專案到打包程式的詳細過程
- 在Web應用中動態建立PDF檔案Web
- maven 建立web工程,spring配置檔案找不到!MavenWebSpring
- Web應用程式黑客與安全專家Web黑客
- 6個建立Web應用程式的高效PHP框架WebPHP框架
- 建立筋斗雲Web介面專案Web
- serverless 專案配置及建立helloworld應用(二)Server
- 如何建立一個Maven專案(eclipse版本)MavenEclipse
- 使用Maven命令列快速建立專案骨架(archetype)Maven命令列