eclipse 构建maven web工程

时间:2021-11-11 18:39:19
  • 新建,maven project eclipse 构建maven web工程 下一步
  • 不要选择 create a simple project,eclipse 构建maven web工程下一步
  • filter 输入webapp,选择webappeclipse 构建maven web工程 下一步
  • 填写 group Id  com.XX  artifactId testXX ,package 可选 
  • eclipse 构建maven web工程 finish
  • 结构如图java视图下eclipse 构建maven web工程 ,javeEEeclipse 构建maven web工程错误原因The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path ,等下maven引入 jsp 相关jar包即可解决
  • 配置项目 已经有了src/main/resource 需要添加src/main/java,src/test/java ,src/test/resources三个文件夹。右键项目根目录点击New -> Source Folder,建出这三个文件夹
  • eclipse 构建maven web工程

  • 更改顺序,可用Order and Exprot 更改后如下eclipse 构建maven web工程
  • 更改输入路径,右键Java Build Path -> Source 下面应该有4个文件夹。src/main/java,src/main /resources,src/test/java ,src/test/resources选上Allow output folders for source folders双击每个文件夹的Output folder,选择路径src/main/java,src/main/resources,选择target/classes;src/test/java ,src/test/resources, 选择target/test-classes;     eclipse 构建maven web工程
  • 更改jre ,选择remove ,add Libray,添加 jre
  • eclipse 构建maven web工程 
  • 把项目变成Dynamic Web项目 右键项目,properties 选择Project Facets,点击 选中 Dynamic Web Module ,OKeclipse 构建maven web工程
  • 设置部署程序集(Web Deployment Assembly) eclipse 构建maven web工程只留下eclipse 构建maven web工程即可,此处列表是,部署项目时,文件发布的路径。         (1)我们删除test的两项,因为test是测试使用,并不需要部署。         (2)设置将Maven的jar包发布到lib下。
  • 构建框架 在pom.xml中添加所需要的jar包 一般添加如下,根据需要的功能添加
  •    
       
    1. <!-- 定义一些属性参数,一般是定义依赖的版本号 -->
    2. <properties>
    3. <junit.version>4.10</junit.version>
    4. <spring.version>4.0.6.RELEASE</spring.version>
    5. <mybatis.version>3.2.7</mybatis.version>
    6. <mybatis.spring.version>1.2.2</mybatis.spring.version>
    7. <mybatis.paginator.version>1.2.15</mybatis.paginator.version>
    8. <mysql.version>5.1.32</mysql.version>
    9. <druid.version>1.0.9</druid.version>
    10. <jstl.version>1.2</jstl.version>
    11. <servlet-api.version>2.5</servlet-api.version>
    12. <jsp-api.version>2.0</jsp-api.version>
    13. <commons-lang3.version>3.3.2</commons-lang3.version>
    14. <commons-io.version>1.3.2</commons-io.version>
    15. </properties>
    16. <dependencies>
    17. <!-- junit -->
    18. <dependency>
    19. <groupId>junit</groupId>
    20. <artifactId>junit</artifactId>
    21. <version>${junit.version}</version>
    22. <scope>test</scope>
    23. </dependency>
    24. <!--JSTL -->
    25. <dependency>
    26. <groupId>jstl</groupId>
    27. <artifactId>jstl</artifactId>
    28. <version>${jstl.version}</version>
    29. </dependency>
    30. <!-- Apache工具组件 -->
    31. <dependency>
    32. <groupId>org.apache.commons</groupId>
    33. <artifactId>commons-lang3</artifactId>
    34. <version>${commons-lang3.version}</version>
    35. </dependency>
    36. <!-- IO处理组件 -->
    37. <dependency>
    38. <groupId>org.apache.commons</groupId>
    39. <artifactId>commons-io</artifactId>
    40. <version>${commons-io.version}</version>
    41. </dependency>
    42. <!-- json工具类 -->
    43. <dependency>
    44. <groupId>com.alibaba</groupId>
    45. <artifactId>fastjson</artifactId>
    46. <version>1.1.41</version>
    47. </dependency>
    48. <!-- Spring -->
    49. <dependency>
    50. <groupId>org.springframework</groupId>
    51. <artifactId>spring-context</artifactId>
    52. <version>${spring.version}</version>
    53. </dependency>
    54. <!-- Spring MVC -->
    55. <dependency>
    56. <groupId>org.springframework</groupId>
    57. <artifactId>spring-webmvc</artifactId>
    58. <version>${spring.version}</version>
    59. </dependency>
    60. <dependency>
    61. <groupId>org.springframework</groupId>
    62. <artifactId>spring-jdbc</artifactId>
    63. <version>${spring.version}</version>
    64. </dependency>
    65. <dependency>
    66. <groupId>org.springframework</groupId>
    67. <artifactId>spring-aspects</artifactId>
    68. <version>${spring.version}</version>
    69. </dependency>
    70. <!-- Mybatis -->
    71. <dependency>
    72. <groupId>org.mybatis</groupId>
    73. <artifactId>mybatis</artifactId>
    74. <version>${mybatis.version}</version>
    75. </dependency>
    76. <dependency>
    77. <groupId>org.mybatis</groupId>
    78. <artifactId>mybatis-spring</artifactId>
    79. <version>${mybatis.spring.version}</version>
    80. </dependency>
    81. <dependency>
    82. <groupId>com.github.miemiedev</groupId>
    83. <artifactId>mybatis-paginator</artifactId>
    84. <version>${mybatis.paginator.version}</version>
    85. </dependency>
    86. <!-- MySql -->
    87. <dependency>
    88. <groupId>mysql</groupId>
    89. <artifactId>mysql-connector-java</artifactId>
    90. <version>${mysql.version}</version>
    91. </dependency>
    92. <!-- 链接池 -->
    93. <dependency>
    94. <groupId>com.alibaba</groupId>
    95. <artifactId>druid</artifactId>
    96. <version>${druid.version}</version>
    97. </dependency>
    98. <!-- JSP相关 -->
    99. <dependency>
    100. <groupId>jstl</groupId>
    101. <artifactId>jstl</artifactId>
    102. <version>${jstl.version}</version>
    103. </dependency>
    104. <dependency>
    105. <groupId>javax.servlet</groupId>
    106. <artifactId>servlet-api</artifactId>
    107. <version>${servlet-api.version}</version>
    108. <scope>provided</scope>
    109. </dependency>
    110. <dependency>
    111. <groupId>javax.servlet</groupId>
    112. <artifactId>jsp-api</artifactId>
    113. <version>${jsp-api.version}</version>
    114. <scope>provided</scope>
    115. </dependency>
    116. <!-- 文件上传组件 -->
    117. <dependency>
    118. <groupId>commons-fileupload</groupId>
    119. <artifactId>commons-fileupload</artifactId>
    120. <version>1.3.1</version>
    121. </dependency>
    122. </dependencies>


  • 发布 对着工程点右键:Run As ->Maven install 

    创建server 切换到javeEE 视图,点击eclipse 构建maven web工程
    eclipse 构建maven web工程
    选择自己的tomcat 版本,名称什么,下一步
    eclipse 构建maven web工程









  • 来自为知笔记(Wiz)