maven 在eclipse中設定以及建立java和web工程__java

來源:互聯網
上載者:User

一、maven 在eclipse中設定

1、maven下載:

https://maven.apache.org/download.cgi 解壓下載好的maven。

2、eclipse中進入Installations下,添加剛剛解壓好的maven

window->Preferences->Maven->Installations->add

添加剛剛解壓好的maven,然後Apply。

3、進入User Settings,設定User Settings。

選擇解壓好maven下的settings.xml。apache-maven-3.5.0\conf\settings.xml。

4、設定編譯的jdk版本

[1]開啟settings.xml檔案
[2]找到profiles標籤
[3]加入如下配置
<profile>
<id>jdk-1.7</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>

二、建立java和web工程

5、

為了方便建立maven工程,先設定一下Menu Visibility 。

Window->Customize Perspective->Menu Visibility->File->New,選Maven Project,然後點ok。

①建立maven的java工程

File->New->Maven Project->勾選create a single project(skip archetype selection) ->next->填寫Group Id->填寫Artifact Id ->Packaging中選擇jar->finish。

②建立maven的web工程

File->New->Maven Project->勾選create a single project(skip archetype selection) ->next->填寫Group Id 比如com.james.ssm->填寫Artifact Id 比如:SSM->Packaging中選擇war->finish。

註:建立maven的java工程和建立maven的web工程 Packaging選擇不一樣。在於Packaging的選擇上,java選的是jar,web選的是war

產生META-INF和WEB-INF目錄和裡面的內容:

選中建立的工程,右擊->Properties->Project Facets->取消選擇Dynamic Web Module->Apply->再選擇Dynamic Web Module->點擊Further configuration available->Content directory中的值改為src/main/webapp,->勾選Generate web.xml deployment descriptor->ok。

③執行maven命令:

選中pom.xml,右擊,run as。




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.