MyEclipse10下Maven搭建web项目

来源:互联网 发布:淘宝优惠券发放平台 编辑:程序博客网 时间:2024/06/07 00:01

今天尝试了用maven搭建web项目。

一开始用myeclipse10自带的插件maven4myeclipse搭建的项目总是不对,后来索性自己去下了个maven插件,尝试了两遍终于成功了,私货不藏,拿出来和大家分享。

先从下载maven插件开始讲起:

help==>MyeclipseConfigCenter==>software==>>addsite

输入 name: maven url:http://m2eclipse.sonatype.org/sites/m2e

双击该插件后开始安装,需要重启myeclipse,等下就可以了。

重启玩了后,返回workbench,我们 右键==〉〉new  ==〉〉other==〉〉maven project

点击next

选择maven-archetype-web

next

点击ok

再new 4个source folder src/main/java

src/main/resources

src/test/java

src/test/resources


右键==〉〉maven ==〉〉enable maven

貌似自动带着junit的,没有的话可以修改下pom.xml。

在src/test/java下新建class test.java

import org.junit.Test;public class test {@Testpublic void test(){System.out.println(123123123);}}

右键run as junit test

或者部署到tomcat上都没有问题



当然maven 可以使用命令行的方式进行配置下载

我现在是在ubuntu下 首先下载maven

sudo apt-get install maven

安装好之后 maven的命令是mvn

配置文件在 /etc/maven/下 m2.conf setting.xml

查看setting.xml

默认的本地仓库实在~/.m2/repository/

现在找到你的工程pom.xml所在目录


 mvn dependency:sources是下载源码

mvn dependency:resolve -Dclassifier=javadoc 是下载doc文档

mvn install  是下载jar包


 <profiles>  <profile>      <id>downloadSources</id>      <properties>          <downloadSources>true</downloadSources>          <downloadJavadocs>true</downloadJavadocs>                 </properties>  </profile>  </profiles>    <activeProfiles>    <activeProfile>downloadSources</activeProfile>  </activeProfiles>

是配置mvn install的时候默认下载所有源码和javadoc







原创粉丝点击