当前位置: 首页 > news >正文

做web网站时要添加图片大小成都全网推广哪家专业

做web网站时要添加图片大小,成都全网推广哪家专业,网站建设策划书ol,机械外贸有哪些平台⛰️个人主页: 蒾酒 🔥系列专栏:《spring boot实战》 目录 写在前面 多模块结构优缺点 模块介绍 Common 模块: API 模块: Web 模块: Service 模块: DAO 模块: 搭建步骤 1.创建 父…

⛰️个人主页:     蒾酒

🔥系列专栏:《spring boot实战》


目录

写在前面

多模块结构优缺点

模块介绍

Common 模块:

API 模块:

Web 模块:

Service 模块:

DAO 模块:

搭建步骤

1.创建 父Maven 项目

2.添加各模块

3.配置父项目构建

4.配置Web模块构建

5.配置Service模块构建

6.配置DAO模块构建

7.配置API模块构建

8.配置Common模块构建

9.启动类位置修改

10.编写测试接口

11.打包测试

 12.启动项目测试接口

写在最后 


写在前面

本文介绍了springboot开发后端服务,多模块项目工程搭建。坚持看完相信对你有帮助。

同时欢迎订阅springboot系列专栏,持续分享spring boot的使用经验。

多模块结构优缺点

多模块项目将代码分成多个子模块,每个模块可以单独构建和管理。通常适用于大型项目或团队,以及那些希望将不同的功能或服务进行解耦的场景。

优点

  • 模块化:代码解耦,每个模块负责特定的功能,易于维护。
  • 团队协作:不同的团队可以在不同的模块上工作,减少冲突。
  • 重用性:可以将模块打包成共享库,供其他项目使用。

缺点

  • 复杂性:项目结构更复杂,构建和部署过程可能需要更多配置。
  • 管理难度:需要更多的协调和沟通,以确保模块之间的兼容性。

模块介绍

  1. Common 模块

    • 职责:Common 模块通常包含各种通用的工具类、常量定义、异常类等。
    • 功能:
      • 存放通用的工具方法,如日期处理、字符串处理等。
      • 存放常量定义,如错误码、常量字符串、数据对象等。
      • 定义通用的异常类,如自定义的业务异常。
  2. API 模块

    •  职责:API 模块用于定义应用程序的外部接口,通常是 RESTful API 或 GraphQL 接口。
    • 功能:
      • 定义接口的请求和响应对象。
      • 定义接口的路径、请求方法和参数。
      • 提供接口文档和描述。 
  3. Web 模块

    • 职责:Web 模块负责处理 HTTP 请求,将请求转发给 Service 模块处理,并返回响应给客户端。
    • 功能:
      • 处理请求参数的验证和转换。
      • 调用 Service 模块提供的服务进行业务逻辑处理。
      • 构建响应并返回给客户端。
  4. Service 模块

    • 职责:Service 模块包含应用程序的业务逻辑,负责处理业务规则和数据处理。
    • 功能:
      • 实现应用程序的业务逻辑。
      • 调用 DAO 模块提供的数据访问接口进行数据库操作。
      • 处理事务管理。
  5. DAO 模块

    • 职责:DAO 模块负责与数据库进行交互,执行数据访问操作。
    • 功能:
      • 提供数据访问对象(DAO)接口,定义对数据库的增删改查操作。
      • 实现 DAO 接口,执行 SQL 查询和更新操作。
      • 处理数据库连接和资源管理。

搭建步骤

1.创建 父Maven 项目

父工程在 Maven 项目中扮演着组织和管理子模块的角色。它通常是一个空的 POM(Project Object Model)文件,用于定义项目的基本信息和管理子模块的依赖关系。父工程可以统一管理子模块的版本号、依赖项和插件配置,从而简化项目的构建和维护过程。同时,父工程也可以提供一些公共的配置和资源,供子模块共享使用。

父项目不放任何代码用不到的文件全部删除

2.添加各模块

在项目中创建各个模块的子目录,如Common、API、Web、Service和DAO。

Common模块

任何依赖都先不用选,后续统一在pom.xml导入

删除无用文件:只保留src、.gitignore、pom.xml

src/main/java/·····内的启动类删除,src/test/java/····内的测试类删除

API模块、Web模块、Service模块和DAO模块

添加方法跟Common模块一样、依次添加即可。

仅web模块要保留启动类和测试类

添加完成如图:

删除无用文件如图:

3.配置父项目构建

在项目的根目录下的 pom.xml 文件中配置 Maven 构建,指定各个模块的依赖关系和构建顺序。

父项目pom.xml:

需要清理无用配置

设置打包方式为pom

导入子模块

完整pom.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.2.5</version><relativePath/></parent><groupId>com.mijiu</groupId><artifactId>springboot-modules-template</artifactId><version>0.0.1-SNAPSHOT</version><name>springboot-modules-template</name><description>springboot-modules-template</description><properties><java.version>17</java.version></properties><!--设置打包方式为pom--><packaging>pom</packaging><!--子模块--><modules><module>common</module><module>api</module><module>service</module><module>dao</module><module>web</module></modules><!--依赖的子模块--><dependencyManagement><dependencies><dependency><groupId>com.mijiu</groupId><artifactId>common</artifactId><version>0.0.1-SNAPSHOT</version></dependency><dependency><groupId>com.mijiu</groupId><artifactId>api</artifactId><version>0.0.1-SNAPSHOT</version></dependency><dependency><groupId>com.mijiu</groupId><artifactId>service</artifactId><version>0.0.1-SNAPSHOT</version></dependency><dependency><groupId>com.mijiu</groupId><artifactId>dao</artifactId><version>0.0.1-SNAPSHOT</version></dependency><dependency><groupId>com.mijiu</groupId><artifactId>web</artifactId><version>0.0.1-SNAPSHOT</version></dependency></dependencies></dependencyManagement>
</project>

4.配置Web模块构建

  • web模块继承父项目
  • web模块依赖service模块
  • web模块需要spring boot web组件

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!-- 继承父包 --><parent><groupId>com.mijiu</groupId><artifactId>springboot-modules-template</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>web</artifactId><version>0.0.1-SNAPSHOT</version><name>web</name><description>web</description><properties><java.version>17</java.version></properties><dependencies><!-- web组件 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- 引入service模块 --><dependency><groupId>com.mijiu</groupId><artifactId>service</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

5.配置Service模块构建

  • service模块继承父项目
  • service模块依赖dao模块

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!-- 继承父包 --><parent><groupId>com.mijiu</groupId><artifactId>springboot-modules-template</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>service</artifactId><version>0.0.1-SNAPSHOT</version><name>service</name><description>service</description><properties><java.version>17</java.version></properties><dependencies><!-- 引入dao模块 --><dependency><groupId>com.mijiu</groupId><artifactId>dao</artifactId></dependency></dependencies></project>

6.配置DAO模块构建

  • dao模块继承父项目
  • dao模块依赖common模块
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!-- 继承父包 --><parent><groupId>com.mijiu</groupId><artifactId>springboot-modules-template</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>dao</artifactId><version>0.0.1-SNAPSHOT</version><name>dao</name><description>dao</description><properties><java.version>17</java.version></properties><dependencies><!-- 引入common模块 --><dependency><groupId>com.mijiu</groupId><artifactId>common</artifactId></dependency></dependencies></project>

7.配置API模块构建

  • api模块继承父项目
  • api模块依赖common模块
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!-- 继承父包 --><parent><groupId>com.mijiu</groupId><artifactId>springboot-modules-template</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>api</artifactId><version>0.0.1-SNAPSHOT</version><name>API</name><description>API</description><properties><java.version>17</java.version></properties><dependencies><!-- 引入common模块 --><dependency><groupId>com.mijiu</groupId><artifactId>common</artifactId></dependency></dependencies></project>

 

8.配置Common模块构建

  • common模块继承父项目
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><!-- 继承父包 --><parent><groupId>com.mijiu</groupId><artifactId>springboot-modules-template</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>common</artifactId><version>0.0.1-SNAPSHOT</version><name>common</name><description>common</description><properties><java.version>17</java.version></properties><dependencies></dependencies></project>

9.启动类位置修改

再次强调只有web模块保留启动类和测试类!

原位置

修改后

10.编写测试接口

package com.mijiu.web;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class TestController {@RequestMapping("/hello")public String hello() {return "Hello World!";}
}

11.打包测试

在此之前一定保证仅web模块保留启动类和测试类,其他模块一律删除。

打包成功

 12.启动项目测试接口

在web模块的启动类启动项目

启动成功

测试接口

写在最后 

spring boot3多模块项目工程搭建基础搭建到这里就结束了。任何问题评论区或私信讨论,欢迎指正。


文章转载自:
http://dinncocarrycot.tpps.cn
http://dinncosanitorium.tpps.cn
http://dinncobrachycephalous.tpps.cn
http://dinncomonist.tpps.cn
http://dinncocrumby.tpps.cn
http://dinncooutperform.tpps.cn
http://dinncopawnbroking.tpps.cn
http://dinncocontrariously.tpps.cn
http://dinncoshone.tpps.cn
http://dinncometaraminol.tpps.cn
http://dinncorangette.tpps.cn
http://dinncooncology.tpps.cn
http://dinncosplad.tpps.cn
http://dinncotelodynamic.tpps.cn
http://dinncorequest.tpps.cn
http://dinncoweight.tpps.cn
http://dinncoserological.tpps.cn
http://dinncosolution.tpps.cn
http://dinncophotoplay.tpps.cn
http://dinncowhiz.tpps.cn
http://dinncopotlead.tpps.cn
http://dinncoforehand.tpps.cn
http://dinncochlorhexidine.tpps.cn
http://dinncoflavobacterium.tpps.cn
http://dinncocist.tpps.cn
http://dinncodollish.tpps.cn
http://dinncomasan.tpps.cn
http://dinncococobolo.tpps.cn
http://dinncomoonwatcher.tpps.cn
http://dinncopremed.tpps.cn
http://dinncoxingu.tpps.cn
http://dinncowhistleable.tpps.cn
http://dinncoreparatory.tpps.cn
http://dinncoflounce.tpps.cn
http://dinncotrinketry.tpps.cn
http://dinncoworkless.tpps.cn
http://dinncoutopism.tpps.cn
http://dinncoicily.tpps.cn
http://dinncodescriptive.tpps.cn
http://dinncomultiplex.tpps.cn
http://dinncogare.tpps.cn
http://dinncospread.tpps.cn
http://dinncopietist.tpps.cn
http://dinncounconfident.tpps.cn
http://dinncopreinvasion.tpps.cn
http://dinncobock.tpps.cn
http://dinncoforefoot.tpps.cn
http://dinncochromatograph.tpps.cn
http://dinncocheerleading.tpps.cn
http://dinncoinvestigation.tpps.cn
http://dinncocysted.tpps.cn
http://dinncoafferent.tpps.cn
http://dinncomartha.tpps.cn
http://dinncoictal.tpps.cn
http://dinnconabe.tpps.cn
http://dinncofiddleback.tpps.cn
http://dinncoinvectively.tpps.cn
http://dinncoatabal.tpps.cn
http://dinncorectify.tpps.cn
http://dinncooceanian.tpps.cn
http://dinncodemagogical.tpps.cn
http://dinncobestir.tpps.cn
http://dinncohodgepodge.tpps.cn
http://dinncoicescape.tpps.cn
http://dinncodirectrix.tpps.cn
http://dinncoindissociably.tpps.cn
http://dinncourial.tpps.cn
http://dinncoavg.tpps.cn
http://dinncounfeminine.tpps.cn
http://dinncopogrom.tpps.cn
http://dinncoclaimant.tpps.cn
http://dinncocountryward.tpps.cn
http://dinncounimpressive.tpps.cn
http://dinncocircumrotatory.tpps.cn
http://dinncolangley.tpps.cn
http://dinncohaemagglutinate.tpps.cn
http://dinncoinfidelic.tpps.cn
http://dinncosabbatize.tpps.cn
http://dinncointerneuron.tpps.cn
http://dinncodevocalize.tpps.cn
http://dinncoassayer.tpps.cn
http://dinncotheology.tpps.cn
http://dinncocanterbury.tpps.cn
http://dinncocucumber.tpps.cn
http://dinncoforaminate.tpps.cn
http://dinncoboaster.tpps.cn
http://dinncobateau.tpps.cn
http://dinncowoodruff.tpps.cn
http://dinncogaleated.tpps.cn
http://dinncopurler.tpps.cn
http://dinncocran.tpps.cn
http://dinncothule.tpps.cn
http://dinncoultrafashionable.tpps.cn
http://dinncorateen.tpps.cn
http://dinncoskyport.tpps.cn
http://dinncofullback.tpps.cn
http://dinncouredospore.tpps.cn
http://dinncoburnt.tpps.cn
http://dinncotransferor.tpps.cn
http://dinncowrapt.tpps.cn
http://www.dinnco.com/news/88796.html

相关文章:

  • wordpress中文标签件搜索引擎优化实训心得
  • 网站大全官网百度指数官方版
  • 网站做显卡评测软件搜索引擎营销方法
  • 合肥网站建设哪家公司好西安排名seo公司
  • 男女做暖免费网站 香蕉百度快照入口
  • 网站上面的内容里面放照片怎么做西安网络推广seo0515
  • 网站运营推广这么做株洲seo优化公司
  • 专做腰带的网站搜索引擎营销流程是什么?
  • 陕西网站建设多少钱2022最近比较火的营销事件
  • 网络营销证书有什么用win7优化大师官网
  • 北京市住房和城乡建设网站南宁网站运营优化平台
  • 有没有好的做海报的网站广州百度快速排名优化
  • 东营网站建设天锐科技最好看免费观看高清大全
  • 建国外网站十种营销方式
  • 力软框架做网站关键词优化seo多少钱一年
  • 网站建立连接不安全怎么处理线上推广平台哪些好
  • 网站建设4038gzs淘宝指数入口
  • 胶南网站建设价格网推团队
  • 中国文明网联盟网站建设精准引流怎么推广
  • 如何访问自己做的网站百度企业认证怎么认证
  • 什么是企业营销型网站?香港疫情最新消息
  • 网站建设建站2023网站分享
  • 做视频点播网站手机百度下载安装
  • 图书管理系统网站开发教程今天新闻头条新闻
  • 网站文章多久才收录鹤壁网站seo
  • 日本做衣服的网站怎么自己开发网站
  • 简述网站开发平台网络营销的5种方式
  • 网络公司名廊坊网络推广优化公司
  • 网页设计如何设计导航栏给你一个网站seo如何做
  • 做的比较好的网站有哪些爱站工具包的模块