springboot多模块开发以及整合dubbozookeeper进⾏服务管理 之前研究了springboot单⼯程的使⽤,参考git地址:
下⾯研究springboot多模块开发的过程。
1.模块简介:
springboot-ssm-soa: ⽗⼯程
springboot-ssm-common: 公共类⼯程,包括⼯具类等(其实这⼀模块还可以再分)
springboot-ssm-bean 实体类⼯程
springboot-ssm-service 服务层接⼝(不包括实现)
springboot-ssm-dao dao层接⼝与实现
springboot-ssm-service-provider 服务层实现
springboot-ssm-web 控制层与页⾯以及静态资源
2.模块详细介绍
2.1 springboot-ssm-soa ⽗⼯程
pom⽂件:定义公⽤的jar包以及引⼊相应模块
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance"
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-soa</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>springboot-ssm-common</module>
<module>springboot-ssm-bean</module>
<module>springboot-ssm-service</module>
<module>springboot-ssm-dao</module>
<module>springboot-ssm-service-provider</module>
<module>springboot-ssm-web</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--springboot单元测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--热加载 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<!-- spring-boot整合mybatis -->
<dependency>
<groupId&batis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<!-- 使⽤事务需要引⼊这个包 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- 引⼊ spring aop 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- 引⼊ redis 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--pagehelper插件 -->
springboot aop<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
<!-- 引⼊ freemarker 模板依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<!-- 引⼊ thymeleaf 模板依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- commons⼯具包 -->
<dependency>
<groupId>org.apachemons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<!-- 阿⾥的fastjson⽤于⼿动转JSON -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.56</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>releases</id>
<url>192.168.0.133:8081/repository/maven-releases/</url> </repository>
<snapshotRepository>
<id>snapshots</id>
<url>192.168.0.133:8081/repository/maven-snapshots/</url> </snapshotRepository>
</distributionManagement>
<build>
<!-- 配置了很多插件 -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
注意:多模块项⽬仅仅需要在启动类所在的模块添加打包插件即可!不要在⽗类添加打包插件,因为那样会导致全部⼦模块都使⽤spring-boot-maven-plugin的⽅式来打包(例如BOOT-INF/com/xxx/xx)。
2.2 springboot-ssm-bean ⼦项⽬
这个模块存放的是项⽬的实体类。
pom⽂件如下:
<?xml version="1.0"?>
<project
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd"
xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-soa</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-bean</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-ssm-bean</name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
</dependencies>
</project>
2.3 springboot-ssm-common ⼦项⽬
存放系统的⼯具类以及⼀些其他配置信息,其实这⼀模块还可以再分。
pom如下:
<?xml version="1.0"?>
<project
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.
xsd"
xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-soa</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-ssm-common</name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-bean</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
2.4 springboot-ssm-dao ⼦项⽬
dao模块,⽤于写dao层接⼝和mapp的xml实现。
pom如下:
<?xml version="1.0"?>
<project xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd" xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-soa</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-ssm-dao</name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-bean</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
applications-dao.properties⽂件内容如下:
>>>>>>>>>>>>
#
# Mybatis settings
#
>>>>>>>>>>>>
#jiazai mybatis peizhiwenjian(**代表任意⽬录,*代表任意多个字符)
mybatis.mapper-locations = classpath:mapper/**/*l
>>>>>>>>>>>>
#
# datasource settings
#
>>>>>>>>>>>>
spring.datasource.driver-class-name= sql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf-8
spring.datasource.username = root
spring.datasource.password = 123456
2.5 springboot-ssm-service ⼦项⽬
service层接⼝,不写实现,实现类单独抽取是为了发布dubbo服务。
<?xml version="1.0"?>
<project xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd" xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-soa</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-ssm-service</name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
2.6 springboot-ssm-service-provider ⼦项⽬
service接⼝实现。单独抽取是为了发布dubbo服务。
<?xml version="1.0"?>
<project
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd"
xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-soa</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-service-provider</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-ssm-service-provider</name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.qlq</groupId>
<artifactId>springboot-ssm-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
推荐文章
热门文章
-
随机森林特征选择原理
2024-10-02 -
自动驾驶系统中的随机森林算法解析
2024-10-02 -
随机森林算法及其在生物信息学中的应用
2024-10-02 -
监督学习中的随机森林算法解析(六)
2024-10-02 -
随机森林算法在数据分析中的应用
2024-10-02 -
机器学习——随机森林,RandomForestClassifier参数含义详解
2024-10-02 -
随机森林 的算法
2024-10-02 -
随机森林算法作用
2024-10-02 -
监督学习中的随机森林算法解析(十)
2024-10-02 -
随机森林算法案例
2024-10-02 -
随机森林案例
2024-10-02 -
二分类问题常用的模型
2024-10-02 -
绘制ssd框架训练流程
2024-10-02 -
一种基于信息熵和DTW的多维时间序列相似性度量算法
2024-10-02 -
SVM训练过程范文
2024-10-02 -
如何使用支持向量机进行股票预测与交易分析
2024-10-02 -
二分类交叉熵损失函数binary
2024-10-02 -
tinybert_训练中文文本分类模型_概述说明
2024-10-02 -
基于门控可形变卷积和分层Transformer的图像修复模型及其应用
2024-10-02 -
人工智能开发技术的测试和评估方法
2024-10-02
最新文章
-
基于随机森林的数据分类算法改进
2024-10-02 -
人工智能中的智能识别与分类技术
2024-10-02 -
基于人工智能技术的随机森林算法在医疗数据挖掘中的应用
2024-10-02 -
随机森林回归模型的建模步骤
2024-10-02 -
r语言随机森林预测模型校准曲线
2024-10-02 -
《2024年随机森林算法优化研究》范文
2024-10-02
发表评论