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依赖于bean,bean依赖于dao,dao依赖于common,所以依赖传递为  web<--service<--bean<--dao<--common

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


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

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、over。

猜你喜欢

转载自blog.csdn.net/SongSir001/article/details/80436415