您的位置:首页 > 编程语言 > Java开发

myeclipse下web项目转maven,并保留WEB.XML

2015-11-04 16:17 260 查看
Myeclipse 2014 maven31,直接右键项目-configure----convert to maven project..2,剪切走在maven不必要的工作目录如webroot并放入src/main/webapp
src/main/webapp当然这个目录可以自己生成的。webapp下文件会自动发布到tomcat项目根目录,有需要直接新建,如WEB-INF3,将java代码放入main/java路径后,选择项目Properties->Java buildpath->source,设置output folder至target下的classes文件夹,需要新建。4.Properties->myeclipse->Deployment Assembly下注意remove webroot,且检查是否有maven依赖,没有的话可以close一下项目再打开。note:于src下的prop文件用以下方法获得:本类.class.getResourceAsStream("/“+”src之下路径“);附上maven pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion><groupId>BugService</groupId><artifactId>BugService</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><name>BugService</name><dependencies><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.0.1</version><scope>provided</scope></dependency><dependency><groupId>javax</groupId><artifactId>javaee-web-api</artifactId><version>6.0</version><scope>provided</scope></dependency></dependencies><build><pluginManagement><plugins><plugin><artifactId>maven-compiler-plugin</artifactId><version>3.1</version><configuration><source>1.7</source><target>1.7</target></configuration></plugin><plugin><artifactId>maven-war-plugin</artifactId><version>2.3</version><configuration><warSourceDirectory>WebRoot</warSourceDirectory><failOnMissingWebXml>false</failOnMissingWebXml></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.3</version><configuration><failOnMissingWebXml>false</failOnMissingWebXml></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><version>2.6</version><executions><execution><phase>validate</phase><goals><goal>copy</goal></goals><configuration><outputDirectory>${endorsed.dir}</outputDirectory><silent>true</silent><artifactItems><artifactItem><groupId>javax</groupId><artifactId>javaee-endorsed-api</artifactId><version>7.0</version><type>jar</type></artifactItem></artifactItems></configuration></execution></executions></plugin></plugins></pluginManagement></build></project>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: