本人一直使用的eclipse, 但都說IDEA 是java界中最好使用的編輯器 ,因此開始了IDEA的學習,最近使用到了 IDEA css
可是,既然編輯器有所差異,因此在使用過程當中也不免遇到一些費勁的事情.html
( 這裏暫不介紹如何安裝, 下載和安裝過程前往: http://www.javashuo.com/article/p-tddpbvpe-ht.html )java
一.導入Maven項目的問題
1. 安裝後運行idea會直接打開以下頁面 , 咱們點擊 Open
web
![](http://static.javashuo.com/static/loading.gif)
2. 選擇本身的項目資源路徑, 能夠直接把項目使用 鼠標拖進 會自動尋找位置,而後點擊 OK
![](http://static.javashuo.com/static/loading.gif)
3. 完成後進入編輯界面
![](http://static.javashuo.com/static/loading.gif)
4. 以後咱們先點開 File -> Other Settings -> Structure for New Projects... 設置全局 JDK
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
以後點擊 Project 應用剛纔添加的 JDK
![](http://static.javashuo.com/static/loading.gif)
5. 設置 Maven 點擊 Other Settings -> Settings for new Projects...
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
點擊 OK 完成設置! ( 若是maven沒法下載jar包的, 請檢查是否聯網,或者 前往maven的 apache-maven-3.3.9\conf\settings.xml 中 設置正確的遠程jar包下載路徑,我這裏設置的阿里雲倉庫 )
![](http://static.javashuo.com/static/loading.gif)
6. 須要讓項目跑起來就要配置Tomcat , 點擊右上角的 Add Configuration...
![](http://static.javashuo.com/static/loading.gif)
首先添加一個新的 tomcatapache
![](http://static.javashuo.com/static/loading.gif)
點擊 Configure 配置tomcat
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
tomcat 路徑配置完成後,再配置如下訪問路徑和端口號. 而後 先不急着點肯定,進行如下第四步 點擊 Deployment
![](http://static.javashuo.com/static/loading.gif)
7. Artfacts ( Web部署 )
繼續以上的配置
如下步驟借鑑 https://www.cnblogs.com/yjd_hycf_space/p/7483921.html 服務器
![](http://static.javashuo.com/static/loading.gif)
估計有的小夥伴們到這個地方,哎,發現,我怎麼就只有一個選項呀,artifact這個選項怎麼沒有呢?app
不要驚慌,eclipse
方法一:maven
先看文章最底部的更新內容,看看是否是由於安裝的編輯器不是開發版,也就是說你安裝的是免費版的,那可能就是少了下面的插件。
看看安裝以後,是否是就能夠搞定問題啦。
後經有同窗反應,你搜索不到插件的,是由於你使用的閹割版的,建議安裝專業版,也就是付費的。
方法二:
![](http://static.javashuo.com/static/loading.gif)
根據如下按鈕進行下一步操做, 沒有如下 按鈕1 的 使用 Shift + Ctrl + Alt + S 彈出窗口
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
爲何要配置 Artifacts ?
先理解下它的含義,來看看官方定義的artifacts:
An artifact is an assembly of your project assets that you put together to test, deploy or distribute your software solution or its part. Examples are a collection of compiled Java classes or a Java application packaged in a Java archive, a Web application as a directory structure or a Web application archive, etc.
即編譯後的Java類,Web資源等的整合,用以測試、部署等工做。再白話一點,就是說某個module要如何打包,例如war exploded、war、jar、ear等等這種打包形式。某個module有了 Artifacts 就能夠部署到應用服務器中了。
(
jar:Java ARchive,一般用於聚合大量的Java類文件、相關的元數據和資源(文本、圖片等)文件到一個文件,以便分發Java平臺應用軟件或庫;
war:Web application ARchive,一種JAR文件,其中包含用來分發的JSP、Java Servlet、Java類、XML文件、標籤庫、靜態網頁(HTML和相關文件),以及構成Web應用程序的其餘資源;
exploded:在這裏你能夠理解爲展開,不壓縮的意思。也就是war、jar等產出物沒壓縮前的目錄結構。建議在開發的時候使用這種模式,便於修改了文件的效果馬上顯現出來。
)
默認狀況下,IDEA的 Modules 和 Artifacts 的 output目錄已經設置好了,不須要更改,打成war包的時候會自動在 WEB-INF目錄下生成classes,而後把編譯後的文件放進去。
接着繼續
![](http://static.javashuo.com/static/loading.gif)
到這,你就能夠添加了,或者直接點右下角的那個fix,估計一下就自動,給搞定了,繼續吧。
更新完畢。
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
這個,沒搞過web開發的小夥伴,可能不大好理解。
在 Java Web 開發中, 通常更新了 Java 文件後要手動重啓 Tomcat 服務器, 才能生效, 有印象沒?我是真的遇到過,當時用的編輯器是eclipse,使用的服務器好像是jboss,浪費很多生命啊, 你如上配置的話, 不管是更新 class 類,css文件,html文件,js文件,仍是更新 Spring 配置文件都能作到立馬生效,大大提升開發效率。
我最下面示範的,我說一刷新頁面,就能夠看到我修改後的效果,就是簡單給你演示下熱部署功能的好處。
給你省去了重啓tomcat的時間。
![](http://static.javashuo.com/static/loading.gif)
有的同窗反應,他沒有如上的這一欄,這個是你配置tomcat以後,纔有的
以後啓動項目 ....
![](http://static.javashuo.com/static/loading.gif)
啓動成功! 完成