在操作之前请确保Maven环境已经塔建完毕了。
一,创建Maven项目
二,补全工程的目录结构
第1步中生成的maven工程目录是不全的,需要手动添加所需的目录。
三,增加MyEclipse的Web Project功能
到目前为止,我们仅仅是把一个Maven的webapp导入到了MyEclipse中,然而在MyEclipse中,这还仅仅是一个Java普通的Maven工程,这一步我们就要为其添加MyEclipse的web project特性。
选择工程-->MyEclipse-->Project Capabilities-->Add Web Project Capabilites,弹出窗口中设置参数如下,再接下来的弹出窗口中选择yes。这样我们的工程就是web工程了(注意工程图标有变化,而且MyEclipse自动依赖了JEE的包)。
同理创建:src/main/webapp
此时项目的结构图如下:
四,配置工程属性,打开工程属性面板
添加src/main/java, src/test/java, src/test/resources为source folder, 这里就不需要详述了吧,点"add folder"就行。
最小面的"default output folder"修改为"mywebapp/src/main/webapp/WEB-INF/classes"---这点很重要
修改这些source folder的输出目录,其中main/java和main/resources输出到default output folder, 而test/java和test/resources输出到target/test-classes中,(如何修改---点击各节点下的Output Folder, 再点右边的edit按钮就行了)最后设置结果如下:
Myeclipse-->Web
这一个是用来修改设置工程的web特性的,如下图:
五,配置pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | < 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 >springMVC</ groupId > < artifactId >springMVC</ artifactId > < version >0.0.1-SNAPSHOT</ version > < packaging >jar</ packaging > < name >springMVC</ name > < url >http://maven.apache.org</ url > < properties > < project.build.sourceEncoding >UTF-8</ project.build.sourceEncoding > </ properties > < dependencies > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-web</ artifactId > < version >4.0.6.RELEASE</ version > </ dependency > < dependency > < groupId >junit</ groupId > < artifactId >junit</ artifactId > < version >4.11</ version > < scope >test</ scope > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >servlet-api</ artifactId > < version >2.5</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-aspects</ artifactId > < version >4.0.6.RELEASE</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-webmvc</ artifactId > < version >4.0.6.RELEASE</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-context-support</ artifactId > < version >4.0.6.RELEASE</ version > </ dependency > < dependency > < groupId >org.freemarker</ groupId > < artifactId >freemarker</ artifactId > < version >2.3.20</ version > </ dependency > < dependency > < groupId >commons-logging</ groupId > < artifactId >commons-logging</ artifactId > < version >1.2</ version > </ dependency > < dependency > < groupId >commons-lang</ groupId > < artifactId >commons-lang</ artifactId > < version >2.6</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-mock</ artifactId > < version >2.0.8</ version > < scope >test</ scope > </ dependency > < dependency > < groupId >log4j</ groupId > < artifactId >log4j</ artifactId > < version >1.2.14</ version > </ dependency > < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis</ artifactId > < version >3.2.7</ version > </ dependency > < dependency > < groupId >org.mybatis</ groupId > < artifactId >mybatis-spring</ artifactId > < version >1.2.2</ version > </ dependency > < dependency > < groupId >mysql</ groupId > < artifactId >mysql-connector-java</ artifactId > < version >5.1.32</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-tx</ artifactId > < version >4.0.6.RELEASE</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-jdbc</ artifactId > < version >4.0.6.RELEASE</ version > </ dependency > < dependency > < groupId >org.apache.commons</ groupId > < artifactId >commons-collections4</ artifactId > < version >4.0</ version > </ dependency > < dependency > < groupId >commons-dbcp</ groupId > < artifactId >commons-dbcp</ artifactId > < version >1.4</ version > </ dependency > < dependency > < groupId >commons-pool</ groupId > < artifactId >commons-pool</ artifactId > < version >1.6</ version > </ dependency > < dependency > < groupId >org.springframework</ groupId > < artifactId >spring-test</ artifactId > < version >4.0.6.RELEASE</ version > < scope >test</ scope > </ dependency > < dependency > < groupId >net.sf.json-lib</ groupId > < artifactId >json-lib</ artifactId > < version >2.4</ version > < classifier >jdk15</ classifier > </ dependency > < dependency > < groupId >org.activiti</ groupId > < artifactId >activiti-engine</ artifactId > < version >5.16.3</ version > </ dependency > < dependency > < groupId >org.activiti</ groupId > < artifactId >activiti-spring</ artifactId > < version >5.16.3</ version > </ dependency > < dependency > < groupId >org.apache.openejb</ groupId > < artifactId >javaee-api</ artifactId > < version >5.0-1</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.faces</ groupId > < artifactId >jsf-api</ artifactId > < version >1.2_04</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.servlet</ groupId > < artifactId >jstl</ artifactId > < version >1.2</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.servlet.jsp</ groupId > < artifactId >jsp-api</ artifactId > < version >2.1</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >javax.faces</ groupId > < artifactId >jsf-impl</ artifactId > < version >1.2_04</ version > < scope >provided</ scope > </ dependency > < dependency > < groupId >io.janusproject.guava</ groupId > < artifactId >guava</ artifactId > < version >17.0</ version > </ dependency > < dependency > < groupId >com.google.code.gson</ groupId > < artifactId >gson</ artifactId > < version >2.3</ version > </ dependency > < dependency > < groupId >org.apache.commons</ groupId > < artifactId >commons-io</ artifactId > < version >1.3.2</ version > </ dependency > < dependency > < groupId >commons-fileupload</ groupId > < artifactId >commons-fileupload</ artifactId > < version >1.3.1</ version > </ dependency > < dependency > < groupId >com.mchange</ groupId > < artifactId >c3p0</ artifactId > < version >0.9.5-pre8</ version > </ dependency > </ dependencies > </ project > |