maven聚合项目搭建,简单的SpringBoot集成

1、new Maven project ,第一行 create a .... 打钩

2、项目结构如下图,可以删除src,只保留pom

3、右键该项目,new   project  选择maven model  点击next,填写model 那么,比如我的 填的是 songsir-web,因为该model我作为应用视图层,项目中的 页面和 controller都包含在改model下,所以next,选择如下图,然后,next finish。

4、接着在新建 model,分别为songsir-service,songsir-bean,songsir-dao,songsir-common,全部选择:

新建完成,目录结构如下:

5、接着,配置各个模块之间的依赖关系。我的依赖关系是:web依赖于service,service依赖于dao,dao依赖于bean,bean依赖于common,所以依赖传递为  web<--service<--dao<--bean<--common

首先在songsir-web下的pom里面添加songsir-service的依赖

同理,在service,dao,bean分别添加下层的依赖。

6、添加完之后,右键 项目,run as  maven install,完成之后,查看songsir-web下,发现,其他模块的依赖都已经引入

至此,maven聚合项目搭建完成,下面引入Springboot依赖即可搭建简单的SpringBoot项目。

7、在项目根目录下pom中添加

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>
    <relativePath />
</parent>

接着,在songsir-common下的pom里添加

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

保存,依赖自动下载,引入。然后发现songsir-web下jar包都已经被引入

8、在sognsir-web下面创建启动类  MyApplication.java。

然后,在com.songsir的下一层包(必须是下一层),创建个普通controller作为测试。

9、run  MyApplication这个类,如下表示启动成功。

然后,在浏览器访问:localhost:8080/helloWorld

10、demo整合mybatis请参考我的github:https://github.com/songsir01/songsir-demoboot

 

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值