我是靠谱客的博主 俊秀小蘑菇,这篇文章主要介绍1、使用maven多module构建一个web后端项目,现在分享给大家,希望可以做个参考。

记录每一个努力的日子!
参考项目:github master分支.

1、工具

idea

2、概述

多模块相比较单体服务,可以使一个项目更加容易管理,避免来回切换项目

3、步骤

3.1

file->new->project(选择 Spring Initializr、 project SDK 1.8)->next(填写 Group、Artifact、选择 Java Version、其他默认)->next->next->finish

3.2

删除src文件

3.3

打开pom.xml,在 <version> 标签下添加

    <packaging>pom</packaging>

修改 <parent> 标签下的 <version> 标签,这里的版本是最新的版本,改一个次新的稳定版本

3.4

右键项目->new->Module(选择 Spring Initializr、 project SDK 1.8)->next(填写 Group、Artifact、选择 Java Version、其他默认)->next->next->finish

3.5

删除子模块的目录下的文件,只保留src、pom.xml

3.6

进入子模块的pom.xml,修改

<parent>
    <groupId>父模块groupId</groupId>
    <artifactId>父模块artifactIdt</artifactId>
    <version>父模块version</version>
    <relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>

添加web依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

3.7

进入父模块pom.xml,添加

<modules>
    <module>子模块artifactIdt</module>
</modules>

3.8

添加controller,启动,测试

最后

以上就是俊秀小蘑菇最近收集整理的关于1、使用maven多module构建一个web后端项目的全部内容,更多相关1、使用maven多module构建一个web后端项目内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部