maven 建立 webapp 项目 有2种方式 , 
1.在原先app上转换为webapp项目 
2.建立maven项目的时候  filter 选择webapp 该选项把webapp文件目录建好,其他的还是要自己配。。。。。

采用将原先的app项目改成 webapp项目 



1.改变项目,动态web工程


让项目成此结构



eclipse   buliders  配置文件

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <projectDescription> 
  3.  <name>mmvc</name> 
  4.  <comment></comment> 
  5.  <projects> 
  6.  </projects> 
  7.  <buildSpec> 
  8.   <buildCommand> 
  9.    <name>org.eclipse.wst.jsdt.core.javascriptValidator</name> 
  10.    <arguments> 
  11.    </arguments> 
  12.   </buildCommand> 
  13.   <buildCommand> 
  14.    <name>org.eclipse.jdt.core.javabuilder</name> 
  15.    <arguments> 
  16.    </arguments> 
  17.   </buildCommand> 
  18.   <buildCommand> 
  19.    <name>org.eclipse.wst.common.project.facet.core.builder</name> 
  20.    <arguments> 
  21.    </arguments> 
  22.   </buildCommand> 
  23.   <buildCommand> 
  24.    <name>org.eclipse.wst.validation.validationbuilder</name> 
  25.    <arguments> 
  26.    </arguments> 
  27.   </buildCommand> 
  28.   <buildCommand> 
  29.    <name>org.eclipse.m2e.core.maven2Builder</name> 
  30.    <arguments> 
  31.    </arguments> 
  32.   </buildCommand> 
  33.  </buildSpec> 
  34.  <natures> 
  35.   <nature>org.eclipse.m2e.core.maven2Nature</nature> 
  36.   <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> 
  37.   <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> 
  38.   <nature>org.eclipse.wst.common.project.facet.core.nature</nature> 
  39.   <nature>org.eclipse.jdt.core.javanature</nature> 
  40.   <nature>org.eclipse.wst.jsdt.core.jsNature</nature> 
  41.  </natures> 
  42. </projectDescription> 


项目 工程下  .settings  ---- .jsdtscope文件修改 java脚本路径

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <classpath> 
  3.  <classpathentry kind="src" path="/src/main/webapp"/>   //改这里
  4.  <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/> 
  5.  <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject"> 
  6.   <attributes> 
  7.    <attribute name="hide" value="true"/> 
  8.   </attributes> 
  9.  </classpathentry> 
  10.  <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/> 
  11.  <classpathentry kind="output" path=""/> 
  12. </classpath> 




配置  web context root deploy-path 目录

如果项目原先为 web工程 ,这时候要换目录则需要进入配置文件改动

项目 工程下  .settings  ---- org.eclipse.wst.common.component文件修改  发布目录

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <project-modules id="moduleCoreId" project-version="1.5.0"> 
  3.     <wb-module deploy-name="mmvc"> 
  4.         <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> 
  5.         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> 
  6.         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resource"/> 
  7.         <property name="context-root" value="mmvc"/> 
  8.         <property name="java-output-path" value="/mmvc/build/classes"/> 
  9.     </wb-module> 
  10. </project-modules> 



文件目录建好之后 ,  为了让java 脚本及配置文件能  auto bulid  需要配置 这2个目自动编译至webapp发布目录 /classes



ok  web项目基本构建完成


2.pom.xml 配置 web 所需要的环境

  1. <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"> 
  2. <modelVersion>4.0.0</modelVersion> 
  3. <groupId>mmvc</groupId> 
  4. <artifactId>mmvc</artifactId> 
  5. <version>1</version> 
  6. <packaging>war</packaging> 
  7. <properties> 
  8. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
  9. <spring.version>3.0.5.RELEASE</spring.version> 
  10. </properties> 
  11. <dependencies> 
  12. <dependency> 
  13. <groupId>org.apache.openejb</groupId> 
  14. <artifactId>javaee-api</artifactId> 
  15. <version>5.0-1</version> 
  16. <scope>provided</scope> 
  17. </dependency> 
  18. <dependency> 
  19. <groupId>javax.faces</groupId> 
  20. <artifactId>jsf-api</artifactId> 
  21. <version>1.2_04</version> 
  22. <scope>provided</scope> 
  23. </dependency> 
  24. <dependency> 
  25. <groupId>javax.servlet</groupId> 
  26. <artifactId>jstl</artifactId> 
  27. <version>1.2</version> 
  28. <scope>provided</scope> 
  29. </dependency> 
  30. <dependency> 
  31. <groupId>javax.servlet.jsp</groupId> 
  32. <artifactId>jsp-api</artifactId> 
  33. <version>2.1</version> 
  34. <scope>provided</scope> 
  35. </dependency> 
  36. <dependency> 
  37. <groupId>javax.faces</groupId> 
  38. <artifactId>jsf-impl</artifactId> 
  39. <version>1.2_04</version> 
  40. <scope>provided</scope> 
  41. </dependency> 
  42. <dependency> 
  43. <groupId>org.springframework</groupId> 
  44. <artifactId>spring-webmvc</artifactId> 
  45. <version>${spring.version}</version> 
  46. <scope>runtime</scope> 
  47. </dependency> 
  48. </dependencies> 
  49. <build> 
  50. <!-- 列出所依赖的 plugin mvn自动选择包含的 --> 
  51. <pluginManagement> 
  52. <plugins> 
  53. <plugin> 
  54. <groupId>org.apache.maven.plugins</groupId> 
  55. <artifactId>maven-compiler-plugin</artifactId> 
  56. <configuration> 
  57. <source>1.6</source> 
  58. <target>1.6</target> 
  59. </configuration> 
  60. </plugin> 
  61. <plugin> 
  62. <groupId>org.eclipse.m2e</groupId> 
  63. <artifactId>lifecycle-mapping</artifactId> 
  64. <version>1.0.0</version> 
  65. <configuration> 
  66. <lifecycleMappingMetadata> 
  67. <pluginExecutions> 
  68. <pluginExecution> 
  69. <pluginExecutionFilter> 
  70. <groupId>org.apache.maven.plugins</groupId> 
  71. <artifactId>maven-dependency-plugin</artifactId> 
  72. <versionRange>[2.0,)</versionRange> 
  73. <goals> 
  74. <goal>copy-dependencies</goal> 
  75. </goals> 
  76. </pluginExecutionFilter> 
  77. <action> 
  78. <ignore /> 
  79. </action> 
  80. </pluginExecution> 
  81. </pluginExecutions> 
  82. </lifecycleMappingMetadata> 
  83. </configuration> 
  84. </plugin> 
  85. </plugins> 
  86. </pluginManagement> 
  87. <plugins> 
  88. <!-- remove jar plugins --> 
  89. <plugin> 
  90. <groupId>org.apache.maven.plugins</groupId> 
  91. <artifactId>maven-clean-plugin</artifactId> 
  92. <executions> 
  93. <execution> 
  94. <id>clean</id> 
  95. <phase>install</phase> 
  96. <goals> 
  97. <goal>clean</goal> 
  98. </goals> 
  99. <configuration> 
  100. <directory>/src/main/webapp/WEB-INF/lib</directory> 
  101. </configuration> 
  102. </execution> 
  103. </executions> 
  104. </plugin> 
  105. <!-- copy jar plugins --> 
  106. <plugin> 
  107. <groupId>org.apache.maven.plugins</groupId> 
  108. <artifactId>maven-dependency-plugin</artifactId> 
  109. <executions> 
  110. <execution> 
  111. <id>copy-dependencies</id> 
  112. <phase>package</phase> 
  113. <goals> 
  114. <goal>copy-dependencies</goal> 
  115. </goals> 
  116. <configuration> 
  117. <outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory> 
  118. <excludeTransitive>false</excludeTransitive> 
  119. <stripVersion>false</stripVersion> <!-- 复制jar 的时候去掉版本信息 true : 去掉 false: 不去掉 --> 
  120. <includeScope>runtime</includeScope> 
  121. </configuration> 
  122. </execution> 
  123. </executions> 
  124. </plugin> 
  125. </plugins> 
  126. </build> 
  127. </project>

以上配置包含 javeee 自带的jar , springmvc 框架 所需jar  ,可以从maven远程仓库获取至本地服务器仓库 ,再 从maven仓库获取

另包含 自动部署的时候 copy jar到 发布目录下的lib目录下

ok 需要生成 package的时候  会自动生成到 target 目录下并打成war包 


maven package执行的时候会遇到jdk版本不对的问题 :原因是 maven所指定的jdk版本与项目使用的jdk版本不一致


跑起来吧 。。。。。。。。。。。。。。。。。。。。

eclipse Maven 使用记录 ------ 建立 webapp项目的更多相关文章

  1. eclipse Maven 使用记录 ------ 建立app项目

    maven 项目构建工具 , 如今已逐渐取代ant的笨拙配置方式 ,使项目管理更加简单,规范,结构更加清晰,这里记录跟eclipse集成的一些步骤  1.从apache maven项目下下载maven ...

  2. 用Eclipse Maven 创建 Web 3.0 项目问题 正确的处理步骤

    在Eclipse 安装好Maven插件后,创建Maven webapp项目,在工程 properties -> project facets 界面中将 Dynamic Web Module 修改 ...

  3. 手工MAVEN建立WEBAPP项目并打包部署

    参考URL: http://my.oschina.net/zimingforever/blog/266028 最简单的东东,可以就两条命令: 建立目录及POM.XML: mvn archetype:g ...

  4. Eclipse Maven 创建Hello World Web项目

    通过Eclipse创建Maven Web项目的简单步骤 先决条件 (Prerequisites) 1,JDK  environment, 具体的安装JDK的步骤和环境配置一般网上都有,这里就不在赘述. ...

  5. eclipse maven jdk1.8 还原站点项目红感叹号总是小结

    问题背景有三 maven 默认是jdk1.5jdk1.8 目录文件夹不全操作: 在项目上右击-> build path-->config build path-->libraries ...

  6. 如何使用maven开启一个webapp项目

    1.使用maven创建好一个webapp项目 2.pom.xml: 第一步:修改版本 <properties> <project.build.sourceEncoding>UT ...

  7. Eclipse+Maven创建webapp项目<一><二><三>

    转-http://www.cnblogs.com/candle806/p/3439469.html Eclipse+Maven创建webapp项目<一> 1.开启eclipse,右键new ...

  8. Eclipse+Maven创建webapp项目<一>(转)

    还在为jar下载而烦恼吗?还在为jar依赖关系而烦恼吗?还在为jar冲突而烦恼吗?强大的maven项目管理工具来拯救你们呢?自动下载jar,自动下载jar依赖包.你什么都不用做,只需要在中央仓库中co ...

  9. Eclipse+maven创建webapp项目<二>(转)

    原文地址:http://www.cnblogs.com/candle806/p/3439469.html 1.开启eclipse,右键new-->other,如下图找到maven project ...

随机推荐

  1. Nginx+FastCGI运行原理(二)

    1.4 PHP与PHP-FPM的安装及优化(2) 标签rlimit_files用于设置PHP-FPM对打开文件描述符的限制,默认值为1024.这个标签的值必须和Linux内核打开文件数关联起来,例如, ...

  2. Nginx配置Awstats分析Nginx日志笔记

    1.修改Nginx日志格式: log_format json '$remote_addr - $remote_user [$time_local] "$request" '     ...

  3. Rust 之 cargo(项目构建和包管理工具)

    如果食用cargo来进行项目构建: 1. 执行 cargo new hello_cargo --bin ,执行完上面的操作之后,我们切换到hell_cargo目录下,可以看到一个文件(Cargo.to ...

  4. JSON之Asp.net MVC C#对象转JSON,DataTable转JSON,List<T>转JSON,JSON转List<T>,JSON转C#对象

    一.JSON解析与字符串化 JSON.stringify() 序列化对象.数组或原始值 语法:JSON.stringify(o,filter,indent) o,要转换成JSON的对象.数组或原始值 ...

  5. Python 文件 seek() 方法

    概述 Python 文件 seek() 方法用于移动文件读取指针到指定位置. 语法 seek() 方法语法如下: fileObject.seek(offset[,whence]) 参数 offset  ...

  6. 《自己动手写框架2》:用200行的DBF解析器来展示良好架构设计

    因为工作关系.须要工作其中,须要读取DBF文件.找了一些DBF读取开源软件,要么是太过庞大,动不动就上万行.要么是功能有问题,编码,长度,总之是没有找到一个很爽的. 在万般无奈之下,我老人家怒从心头起 ...

  7. 什么是Web缓存控制(基于HTTP头域)

    这是一篇转载的知识性的文档,主要目的是为了让Web缓存相关概念更容易被开发者理解并应用于实际的应用环境中.为了简要起见,某些实现方面的细节被简化或省略了.如果你更关心细节实现则完全不必耐心看完本文,后 ...

  8. IntelliJ IDEA设置代码括号对齐方式

    IntelliJ IDEA设置代码括号对齐方式 IntelliJ IDEA默认的对齐方式如下:括号跟函数名在一行 想改为括号独自占一行,如下: 配置方式如下:File->Setting-> ...

  9. unity, unity默认的Arial字体在编译出的h5版本中不显示

    unity默认的Arial字体在编译出的h5版本中不显示.改用自己的字体可显示.

  10. AWS & ASP.NET

    https://dotnetcodr.com/amazon-cloud/ Amazon cloud Big Data overall architecture Architecture of a Bi ...