vscodemaven 配置_vscode如何新建多模块的maven项目?

vscode新建多模块的maven项目指导意见

此方法适用于任何工具构建maven多模块项目新建一个maven项目A, 直接添加或修改打包结果为pom文件(不能含有任何java代码)

新建一个maven项目B, 放到项目A的pom.xml文件的同一目录下

在项目A的pom.xml文件里面添加如下配置

项目B文件夹名称

4. 在项目B的pom.xml文件里面添加如下配置

项目A的groupId

项目A的artifactId

项目A的版本

最后文件结构类似:项目AA的pom.xml

A的其他文件

项目BB的pom.xml

B的其他文件

随后项目B就继承了项目A的所有依赖环境和默认配置,同时按照此种方式可以添加任意多的类似B项目的子模块.

随后需要解决一个痛点就是子模块和子模块之间如何依赖

假设已经按上述方法配置好了项目ABC,其中A是父pom模块,项目B和项目C都依赖于A

项目B同时还依赖C, 就需要如下操作在项目B的pom.xml文件里面找到dependencies节点

添加一个dependency子节点,里面的内容就是项目C的唯一定位, 比如

项目C的groupId

项目C的artifactId

项目C的版本

此时, 项目B里面就可以使用项目C里面的public类了

推测应该是maven管理了所有的项目后会根据依赖自动管理如何构建的顺序

指导性质的意见讲解完了, 下面说明一下出处

maven官方网站里面有一个如何构建模块的小节(点下面就是)Guide to Working with Multiple Modules​maven.apache.org

进入以后下面有一个更详细的在线example讲解网站的第6章TheNEXUS | A Community Project​books.sonatype.com

第6章是多模块的构建,第7章是企业级多模块构建,也就比第6章多了子模块之间如何相互依赖

假如上面写的过程无法理解, 同时英文官方网站又看不进去, 怎么办?

下面提供一个链接,是那个在线example里面的所有例子的zip压缩包, 直接看源代码吧http://books.sonatype.com/mvnex-book/mvnex-examples.zip​books.sonatype.com如果想把项目放到不同的文件夹里面,可以学习一下pom.xml中relativePath节点

模块依赖里面等价写法./项目B文件夹名称

和relativePath节点一样可以是相对或绝对路径, 只要能找到pom.xml文件就好pom项目可以继承pom项目

警告:如果父pom文件里面包含spring-boot的依赖,就不要在父pom或工具包里面添加下面的代码

org.springframework.boot

spring-boot-maven-plugin

报错信息如下:

Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.6.RELEASE:repackage failed: Unable to find main class

哪里有运行springboot主程序的地方, 哪里才需要springboot插件来生成jar包,其他都使用默认方式生成即可警告:如果在vscode只打开多模块项目里面的一部分会有如下错误

*.java is not on the classpath of project iamparent, only syntax errors are reported

正确做法是将所有模块的文件夹都添加到工作区

2020/06/27更新

后期发现vscode还是无法直接打开多模块的maven项目,还是eclipse或者idea比较好

如果非要拆分项目为多模块,建议使用springcloud微服务

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Cornerstone is a version control app built on Subversion that makes serious version control easier than ever. With full support for all of Subversion's rich features, it's both incredibly powerful and super-easy to use. HIGHLIGHTS • Streamlined workflow for previewing your changes before committing them. • Super-helpful checklist and preview take the guesswork out of Merging. • Class-leading text comparison and editing so you'll never miss a change. • Ingenious annotations that tell you the Who? Why? and When? of every piece of your files. • Log and Timeline views make navigating your project's history a breeze. • Zero configuration: everything you need is included in the app. FEATURES Repositories: • Create new repositories or connect to existing ones • Organize repositories in source lists • Option-drag to create tags and branches • Drag from Finder to import Working Copies: • Organize working copies in source list • Add existing working copies by dragging from Finder • Change summary (including available repository updates), top folder status and activity shown in source list • Displays local and remote file status • Quick Look working copy files • Powerful filtering by modification and lock status as well as by file name • Configure which application to open files with by type and by file • Inspect and modify Subversion properties • Full support for sparse working copies with folder depth extension and reduction Integrated Compare View: • Compare text and images • Syntax coloring for C/C++, CSS, HTML, Javascript, Objective-C, PHP, Ruby and many more • Most image formats supported including PNG, JPEG, GIF and PSD • Highlights intraline differences • Edit working versions by rejecting/restoring individual changes Commit View: • Include and exclude files • Commit changes to folder properties without including nested files • Compare files without leaving commit view Branching and Merging: • Dedicated View for tagging and branching • Merge support for Synchronization, Reintegration, Cherry Picking and Advanced strategies. • Merge preview and checklist to reduce risk of conflicts Log View: • Displays history as list of revisions grouped by date • Filter by text, change type or age • Integrated compare view Annotations: • Seamless integration of blame information into the compare view • Color-coded author display • Legend window with detailed statistics and timeline • Navigate through a file's constituent revisions Timeline View: • Compact horizontal timeline • Compare history for multiple items • Powerful set of filters • Branch points are clearly marked and can be expanded and collapsed Transcript View: • Describes all activities performed in working copy or repository • Detailed progress information for lengthy operations • Saved to disk between application sessions Externals Editor: • List view displays definitions as simple list • Filter for definitions referencing HEAD or a specific revision • Property text can also be edited directly in text view Full Documentation: • Full application documentation in Apple Help Book format • Describes best-practice workflows for working with Subversion Requirements - MacOSX 10.6.6 or Later

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值