使用Eclipse创建Maven项目

把Maven配置到Eclipse

1、修改本地仓库路径:打开Maven目录D:\Java\apache-maven-3.3.9\conf,修改settings.xml文件

<localRepository>D:\Java\repository</localRepository>
   
   

2、配置Maven程序:打开Eclipse-->Window-->Preferences-->Maven-->Installations

3、配置User Settings,让eclipse知道Maven仓库位置

4、构建索引:打开Eclipse-->Window-->Show View-->Other-->Maven Repositories,右键Local Repositoy(注意后面仓库路径是否正确,如不正确请刷新),点击Rebuild Index

Eclipse新建Maven项目

1、新建Maven Project

2、跳过原型选择,创建相对完整目录结构的Maven项目

3、填写项目信息

4、创建好的web项目会报错,在src/main/webapp新建WEB-INF,创建web.xml

5、原来jdk编译版本1.5,在pom.xml中添加插件,修改jdk版本信息,并刷新Maven项目


   
   
  1. <!-- 添加项目jdk编译插件 -->
  2. <build>
  3. <plugins>
  4. <plugin>
  5. <groupId>org.apache.maven.plugin </groupId>
  6. <artifactId>maven-compiler-plugin </artifactId>
  7. <version>3.5.1 </version>
  8. <configuration>
  9. <source>1.7 </source>
  10. <target>1.7 </target>
  11. <encoding>UTF-8 </encoding>
  12. </configuration>
  13. </plugin>
  14. </plugins>
  15. </build>

6、查找依赖

依赖范围

Maven项目标准目录结构

坐标定义

pom基本设置


   
   
  1. <!-- 指定了当前pom的版本 -->
  2. <modelVersion>4.0.0 </modelVersion>
  3. <!-- 反写的公司网址+项目名 -->
  4. <groupId>cn.feicui </groupId>
  5. <!-- 项目名+模块名 -->
  6. <artifactId>BOS_1 </artifactId>
  7. <!-- 0.0.1:第一个0表示大版本号,第二个0表示分支版本号,第三个0表示小版本号 -->
  8. <!-- snapshot快照,alpha内部测试,beta公测,release稳定,GA正式发布 -->
  9. <version>0.0.1-SNAPSHOT </version>
  10. <!-- war,jar,pom -->
  11. <packaging>war </packaging>
  12. <!-- 项目描述名 -->
  13. <name> </name>
  14. <!-- 项目地址 -->
  15. <url> </url>
  16. <!-- 项目描述 -->
  17. <description> </description>
  18. <developers> </developers>
  19. <licenses> </licenses>
  20. <organization> </organization>
  21. <!-- 依赖列表 -->
  22. <dependencies>
  23. <dependency>
  24. <groupId> </groupId>
  25. <artifactId> </artifactId>
  26. <version> </version>
  27. <type> </type>
  28. <!-- 依赖范围 -->
  29. <!-- 1. complie 默认,所有范围 -->
  30. <!-- 2. provided 编译和测试 -->
  31. <!-- 3. runtime 测试和运行 -->
  32. <!-- 4. test 只有测试Junit -->
  33. <!-- 5. system 编译和测试,可移植性差 -->
  34. <!-- 6. import 导入范围,只在实用dependencyManagement中表示从其他pom导入dependency -->
  35. <scope>test </scope>
  36. <!-- 设置依赖是否可选,默认false继承,设置成true必须显示引入依赖-->
  37. <optional> </optional>
  38. <!-- 排除依赖传递列表 -->
  39. <exclusions>
  40. <exclusion> </exclusion>
  41. </exclusions>
  42. </dependency>
  43. </dependencies>
  44. <!-- 依赖的管理 -->
  45. <dependencyManagement>
  46. <dependencies>
  47. <dependency> </dependency>
  48. </dependencies>
  49. </dependencyManagement>
  50. <build>
  51. <!-- 插件列表 -->
  52. <plugins>
  53. <plugin>
  54. <groupId> </groupId>
  55. <artifactId> </artifactId>
  56. <version> </version>
  57. </plugin>
  58. </plugins>
  59. </build>
转载:https://blog.csdn.net/lovecuidong/article/details/115922293
  • 6
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值