第1節(jié)
eclipse與maven集成
用新安裝的MAVEN替代eclipse自帶的maven
1)installations:替換eclipse自帶的maven
window-preference-maven-installations-add-
dictionary-選擇maven的安裝目錄 -finish
2)User Settings:應(yīng)用maven配置文件setting.xml
window-preference-maven-user settings -global setting-D:\apache-maven-3.3.9\conf\settings.xml-apply
測(cè)試是否好用
1)file-new-maven project-next
2)-下一步-create a simple project
2)
group id:一般輸入組織域名 com.neuedu
artifact id:項(xiàng)目名 mavenstudy
如果成功槽卫,會(huì)出現(xiàn)叫mavenstudy的項(xiàng)目
如何下載依賴的jar
工程右鍵-maven-update project
新建web項(xiàng)目
新建web項(xiàng)目時(shí)解決以下問題
錯(cuò)誤原因及解決
原因是缺少webapp\WEB-INF/web.xml
操作之后妻柒,自動(dòng)生成了web.xml
第2部分學(xué)生練習(xí)
maven坐標(biāo)
<groupId>com.neuedu</groupId> 組id (必須)
<artifactId>maven</artifactId> 項(xiàng)目id (必須)
<packaging>war</packaging> 包類型 (必須)
<version>0.0.1-SNAPSHOT</version> 版本 (可選芥喇。默認(rèn)jar)
<classifier> <classifier> (不能定義)
jar 包搜索方法
jar包依賴
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
....
</dependencies>
名詞解釋:
project:項(xiàng)目
pom:項(xiàng)目對(duì)象模型 pom.xml是配置文件
groupid:組織域名,java項(xiàng)目里的包名
artifact Id:一般為項(xiàng)目名
plug-in:插件
repository:倉(cāng)庫(kù)/倉(cāng)儲(chǔ)
pom.xml (工程里)
setting.xml(maven的主配置文件)
build path
build path里將tomcat加進(jìn)來美尸。啟動(dòng)工程
http://localhost:8080/index.jsp
出現(xiàn)正常頁(yè)面(hello world)即完成