Maven有自己的一套约定目录规则,与MyEclipse的有冲突,其实结合也很简单,因为MyEclipse的目录可配置。
1 用maven创建一个web project
mvn archetype:create -DgroupId=com.lifesting -DartifactId=test -DarchetypeArtifactId=maven-archetype-webapp
2 补全某些目录
cd test\src
mkdir main\java
mkdir test\resources
mkdir test\java
3 修改pom文件,在生成eclipse项目的时候maven eclipse plugin使用此配置
在project/build下面插入
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<projectnatures>
<java.lang.String>com.genuitec.eclipse.j2eedt.core.webnature</java.lang.String>
<java.lang.String>org.eclipse.jdt.core.javanature</java.lang.String>
</projectnatures>
<outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>
</configuration>
</plugin>
</plugins>
project nature是eclipse开发中一个概念,比如加入javanature就表示此项目是一个java project,会绑定一个java builder用来编译java文件,而webnature告诉MyEclipse这是一个MyEclipse web项目,更多MyEclipse projectNature:
webservice-- com.genuitec.eclipse.ws.xfire.wsnature
facelet-- com.genuitec.eclipse.jsf.faceletsnature
jsf--com.genuitec.eclipse.jsf.jsfnature
struts--com.genuitec.eclipse.cross.easystruts.eclipse.easystrutsnature
或者在插件里面使用这个方法:
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
try {
String[] natures = project.getDescription().getNatureIds();
for (String nature :natures)
System.out.println(nature);
} catch (CoreException e) {
e.printStackTrace();
}
可以将项目所有的nature打印出来
outputDirectory主要是告诉maven eclipse plugin编译输出在什么位置,默认在target/classes下面,web项目不同,应该放在src/main/webapp/WEB-INF/classes 才能够被MyEclipse package到服务器。
4 在命令行test目录下运行mvn eclipse:eclipse生成Eclipse项目。
5 在MyEclipse中将test project 导入到workspace,MyEclipse通过projectNature识别到test是一个MyEclipse web project,它会在项目目录下生成一个.mymetadata文件。再关闭MyEclipse,这么做的原因是因为默认MyEclipse的webRoot不可配置。
6 修改MyEclipse下面的.mymetadata文件,比如我的test项目文件内容为
<?xml version="1.0" encoding="UTF-8"?>
<project-module
type="WEB"
name="test"
id="myeclipse.1207117121765"
j2ee-spec="1.4"
archive="test.war">
<attributes>
<attribute name="webrootdir" value="/WebRoot" />
</attributes>
</project-module>
增加一行,修改一行为:
<?xml version="1.0" encoding="UTF-8"?>
<project-module
type="WEB"
name="test"
id="myeclipse.1207117121765"
context-root="/test""
j2ee-spec="1.4"
archive="test.war">
<attributes>
<attribute name="webrootdir" value="/src/main/webapp" />
</attributes>
</project-module>
可以看到,增加的一行 context-root="/test" 表示web的上下文为test.
修改的一行为webrootdir的值,将/WebRoot改为maven默认的web项目source目录/src/main/webapp。
7 重新启动MyEclipse,一切搞定了,调试开发两不误。
参考资料
http://www.myeclipseide.com/PNphpBB2-viewtopic-t-17416.html
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lusterfly/archive/2009/09/25/4595456.aspx
分享到:
相关推荐
myeclipse 上安装 Maven3,教你如何配置 maven结合myeclipse使用。maven项目开发必配项
Maven安装包 结合MyEclipse管理开发项目 高效 快捷,报告和文档的软件项目管理工具
结合疫情情况的婚恋-结合疫情情况的婚恋系统-结合疫情情况的婚恋系统源码-结合疫情情况的婚恋管理系统-结合疫情情况的婚恋管理系统java代码-结合疫情情况的婚恋系统设计与实现-基于springboot的结合疫情情况的婚恋...
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若...
结合疫情情况的婚恋-结合疫情情况的婚恋系统-结合疫情情况的婚恋系统源码-结合疫情情况的婚恋管理系统-结合疫情情况的婚恋管理系统java代码-结合疫情情况的婚恋系统设计与实现-基于springboot的结合疫情情况的婚恋...
运行环境:Eclipse:eclipse4.7.3a 、Java:jdk1.7.0_80 、Tomcat:apache-tomcat-8.0.53 、Spring:springsource-tool-suite-3.9.4.RELEASE-e4.7.3a-updatesite 、Maven:apache-maven-3.2.2
结合疫情情况的婚恋系统代码 java结合疫情情况的婚恋系统代码 基于springboot的结合疫情情况的婚恋系统代码 1、结合疫情情况的婚恋系统的技术栈、环境、工具、软件...有任何使用问题欢迎随时与博主沟通,第一时间进行
结合疫情情况的婚恋系统代码 java结合疫情情况的婚恋系统代码 基于springboot的结合疫情情况的婚恋系统代码 1、结合疫情情况的婚恋系统的技术栈、环境、工具、软件...有任何使用问题欢迎随时与博主沟通,第一时间进行
基于SpringBoot+Vue的结合疫情情况的婚恋系统源码+数据库.zip 高分通过项目,已获导师指导。 本项目是一套基于Springboot的结合疫情情况的婚恋系统,主要针对计算机相关专业的正在做毕设的学生和...Maven包:Maven3.3.9
Maven包:Maven3.3.9 基于springboot的结合疫情情况的婚恋系统源码。非常完整的项目源码,加注释说明,新手也可自己动手。框架整体采用springboot,java语言开发,可做为毕业设计和期末大作业。想拿高分的看过来! ...
基于springboot结合疫情情况的婚恋系统 开发语言:Java 框架:springboot JDK版本:JDK1.8 服务器:tomcat7 数据库:mysql 5.7(一定要5.7版本) 数据库工具:Navicat11 开发软件:eclipse/myeclipse/idea Maven包:...
音乐网站与分享平台 ,结合java技术以及MYSQL数据库进行设计,采用B/S架构。音乐网站与分享平台的主要使用者分为管理员和用户,主要包括三个模块: (1)管理员模块:系统中的核心用户是管理员,管理员登录后,通过...
Java毕业设计基于Springboot的结合疫情情况的婚恋系统的实现.zipJava毕业设计基于Springboot的结合疫情情况的婚恋系统的实现.zipJava毕业设计基于Springboot的结合疫情情况的婚恋系统的实现.zip 以下为开发环境 ...
基于SpringBoot的在线答疑系统的研究与实现 开发语言:Java 框架:springboot JDK版本:JDK1.8 服务器:tomcat7 ...分析功能调整与在线答疑系统实现的实际需求相结合,讨论了java开发在线答疑系统的使用。
基于java,springboot的论旅游管理系统设计与实现,Java项目,SpringBoot项目,含开发文档 环境配置: 框架:springboot ...分析功能调整与旅游管理系统实现的实际需求相结合,讨论了Java开发旅游管理系统的使用。
java毕业设计之结合疫情情况的婚恋系统(springboot项目源码+说明文档) 项目可正常启动,以下为开发所需环境: 开发语言:Java 框架:springboot JDK版本:JDK1.8 服务器:tomcat7 数据库:mysql 5.7(5.7版本) ...