maven创建web工程,并导入到eclipse中
maven版本:3.1.0,eclipse版本:4.3 JDK:1.7
创建工程名是sa的maven工程
mvn archetype:create -DgroupId=com.bing-DartifactId=sa -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
进入到创建的工程sa,再执行mvn eclipse:eclipse -Dwtpversion=2.0
在生成的.classthpath文件里面添加
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
修改POM.xml,
添加
<properties>
<spring.version>3.1.1.RELEASE</spring.version>
<junit.version>4.11</junit.version>
<jdk.version>1.7</jdk.version>
</properties>
修改<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
修改<build>,添加
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
把工程导入到eclipse中。
添加src/main/java, src/test/java, src/test/resources三个source folder,在configuration build path里面,选中source面板,选中allow output folders for source folders,更改class的输出路径(main中的存在target/classeses, test存在target/test/classes里面)
提示:
- 导入成功后,需要更改Project Facets里面的java版本和Dynamic Web Module版本。
- 当在POM里面添加jar或添加src/main/java等source folder时,工程会报错,只是因为.classpath文件发生了变化,需要更新工程,只需要右键点击工程,maven-->update即可。
maven创建web工程,并导入到eclipse中的更多相关文章
- 在Eclipse中使用Maven创建Web工程
在Eclipse中使用Maven创建Web工程 1.创建maven Project工程,使用maven-archetype-webapp 2.在pom.xml文件中,设置打包类型为war <pa ...
- maven创建web工程Spring配置文件找不到问题解决方案
使用maven创建web工程,将Spring配置文件applicationContext.xml放在src/resource下,用eclipse编译时提示class path resource [ap ...
- maven创建web工程Spring配置文件找不到
使用maven创建web工程,将Spring配置文件applicationContext.xml放在src/resource下,用eclipse编译时提示class path resource [ap ...
- 初次使用maven创建web工程发现只有一个idea目录,src,webapp目录都不见了,解决方案
修bug系列2之 初次使用maven创建web项目的src目录不知所踪 窗外下着下雨,屋内的我学着maven,本以为轻轻松松,没想到还是遇到了bug.好了不说了,来看看我是怎么解决的. 在初次使用ma ...
- Maven创建Web工程并执行构建/测试/打包/部署
创建工程基本参考上一篇Java Application工程,不同的是命令参数变了,创建Web工程的命令如下: mvn archetype:generate -DgroupId=com.jsoft.te ...
- 基于eclipse+maven创建web工程
Eclipse+Maven创建webapp项目<一> 1.开启eclipse,右键new——>other,如下图找到maven project 2.选择maven project,显 ...
- 如何使用Maven创建web工程(详细步骤)
使用eclipse插件创建一个web project 首先创建一个Maven的Project例如以下图 我们勾选上Create a simple project (不使用骨架) 这里的Packing ...
- maven创建web工程
使用eclipse插件创建一个web project 首先创建一个Maven的Project如下图 我们勾选上Create a simple project (不使用骨架) 这里的Packing 选择 ...
- 用maven创建web工程
1.打开eclipse,选择File->New->Other菜单,弹出下面的对话框,在Wizards中输入maven,会过滤出和maven相关的菜单,选中Maven Project菜单,然 ...
随机推荐
- C语言判断文件是否存在(转)
int access(const char *filename, int amode); amode参数为0时表示检查文件的存在性,如果文件存在,返回0,不存在,返回-1. 这个函 ...
- slide.js使用文档
<!doctype html> <head> <script src="js/jquery-latest.min.js"></script ...
- thinkphp几个表的数据合并,并用数组分页
控制器: //金币扣除 public function jbkc(){ $map['UG_dataType']= 'xtkc'; $list1 = M ( 'userget' )->where ...
- 把textarea右下角的灰点去掉
这个是浏览器自带功能,那个区域属于滚动条的占位区 使textarea可以调整size,加 style="resize:none"可解决,添加多行文字时还是会出现滚动条的.
- lr中定义字符串变量
需要注意的是数组必须定义为固定的长度,如:char chary[20]: 5C2o"Go!\gm nHH0 数组的最大长度为32064(32K),否则会出现“too many variab ...
- 通俗理解T检验与F检验的区别【转】
转自:http://blog.sina.com.cn/s/blog_4ee13c2c01016div.html1,T检验和F检验的由来一般而言,为了确定从样本(sample)统计结果推论至总体时所犯错 ...
- Type.GetField 修改类中私有字段。
上一篇Popup Bug中修改了SystemParameters类中静态只读属性MenuDropAlignment. var t = typeof(SystemParameters); var fie ...
- ZJOI2016 Round 1 之前
day 0 中午要出发了,很虚.. 主要原因: 1.在转语言 2.模板还没有系统整理过 3.最近代码能力感觉要狗带 4.急于想为联赛翻盘... MARK几个未完成的任务 1.字符串处理再去看看..实在 ...
- ural 1250. Sea Burial
1250. Sea Burial Time limit: 1.0 secondMemory limit: 64 MB There is Archipelago in the middle of a s ...
- JS保留小数点(四舍五入、四舍六入)实例
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...