1. 程式人生 > >Idea部署專案到tomcat時沒有artifacts

Idea部署專案到tomcat時沒有artifacts

一、首先建立一個用gradle構建的專案:File-->new --->Project 勾選Java和web-->一路next建立完專案

二、配置tomca:進入Edit Configurations -->左上角+號,tomcat Service -->local(可自定義tomcat 名字)--->Deployment

此時介面下面會有警告:Warning:No artifacts configured 

這時就必須要配置Atrifacts了,在 Edit Configurations中選擇Deployment 中新增xxx.war(exploded),即上圖中:Deployment--->點選如圖示的“+”號,但是有時候發現沒有Artifact這個屬性!!

三、解決上述問題的方法:

1.如果是用maven構建專案那麼解決方法為:File---setting--build,Execution,deployment---maven ----importing---選擇import maven projects automatically-->apply--ok

2.但是!!這裡用的是gradle構建方式,用gradle 構建時Atrifacts本來是自動建立的,而沒有自動建立則是idea與gradle版本不匹配,解決方法為更換gradle版本或者用預設的gradle:File---setting--build,Execution,deployment---Gradle---選擇use default gradle wrapper 或者user gradle wrapper task configuration----apply--ok

四、退出上面介面後,再次進入Edit Configurations配置Tomcat,此時就會有Atrifacts這個選項了

選擇有exploded的選項,應用確定後即可

至此,這個問題解決,新建的這個專案執行後就能跑起來了