1. 程式人生 > >idea mavan 匯出依賴jar包

idea mavan 匯出依賴jar包

IntelliJ IDEA14之後的版本,沒有import project選項,需要在File-New-Project form existing sources,然後基本就都知道咋弄了,然後勾上Import maven projects automatically選項,接下來要把SDK配置好,即找到jdk1.8的位置,最後確認。然後系統會自動下載依賴包,在依賴包下載完之前,整個專案結構是不會顯示出來的,所以即使沒有看到專案目錄也不要著急,等到下載完後,就可以用了。
當有properties檔案時,剛剛匯入後,專案可能找不到它,這時需要右鍵resource資料夾,然後選擇mark directory as–Resources root,這樣就可以成功找到配置檔案了。
IDEA將maven專案打成jar包:
首先要在pom裡<dependencies>和<repositories>間增加<bulid>屬性,build配置資訊如下。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeScope>provided</excludeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>