Maven和IntelliJ IDEA搭建多模塊微服務(wù)的實現(xiàn)
基于Spring Boot、Spring Cloud、Spring Cloud Alibaba的微服務(wù)開發(fā),組件眾多。因此,在創(chuàng)建項目伊始,就應(yīng)當(dāng)考慮版本的管理。以Spring Boot的版本升級發(fā)布為基礎(chǔ),Spring Cloud的版本升級發(fā)布,會匹配Spring Boot升級發(fā)布的版本。Spring Cloud Alibaba版本升級發(fā)布,會匹配Spring Boot和Spring Cloud的版本升級發(fā)布的版本
本例版本:
Spring Boot 2.6.3
Spring Cloud 2021.0.1
Spring Cloud Alibaba 2021.0.1.0
Apache Maven 3.6.3
IntelliJ IDEA 2021.2.3
JDK 1.8
Spring Framework 5.3.15
本例實現(xiàn)基于Maven和IntelliJ IDEA搭建多模塊微服務(wù)項目(工程)。
第一層級工程,只管理第二層級工程。
第二層級工程,管理第三層級工程。
以此類推,使用pom.xml中的modules和module標簽管理維護關(guān)系。
1.規(guī)劃微服務(wù)
規(guī)劃微服務(wù)如表格。

2.創(chuàng)建hub-example
hub-example,是頂級工程,是一個聚合工程,用來管理工程所有模塊。在hub-example中的src目錄不寫代碼,可以刪除。在pom.xml中打包方式配置為pom。
2.1 創(chuàng)建Maven工程
運行IDEA,依次選擇菜單File->New->Project進入New Project對話框,如下配置。

2.2 配置工程信息
hub-example工程配置信息。

2.3 創(chuàng)建完成
項目創(chuàng)建完成如圖,項目初始列表,pom.xml初始化文件

3.配置hub-example的pom.xml
配置hub-example的pom.xml,包括以下幾點內(nèi)容,細節(jié)在pom.xml查看。
(1)配置打包方式。
(2)配置核心依賴。
(3)配置版本管理。
(4)配置打包插件。
(5)配置yml文件讀取pom文件的標簽值。
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hub</groupId>
<artifactId>hub-example</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>hub-dependencies</module>
<module>hub-common</module>
<module>hub-ware</module>
</modules>
<!--(1)配置打包方式(2)配置核心依賴(3)配置版本管理(4)配置打包插件(5)配置yml文件讀取pom文件的標簽值。-->
<!--聚合工程,打包方式:pom-->
<packaging>pom</packaging>
<!-- 版本管理 -->
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring.boot.version>2.6.3</spring.boot.version>
<spring.cloud.version>2021.0.1</spring.cloud.version>
<spring.cloud.alibaba.version>2021.0.1.0</spring.cloud.alibaba.version>
<!-- 統(tǒng)一管理hub-example的版本,在子模塊直接使用此版本即可-->
<hub.example.version>1.0-SNAPSHOT</hub.example.version>
<spring.boot.maven.plugin.version>2.6.3</spring.boot.maven.plugin.version>
<mysql.version>5.1.47</mysql.version>
<druid.version>1.1.23</druid.version>
<pagehelper.version>1.4.1</pagehelper.version>
<mybatis.version>2.2.0</mybatis.version>
<mybatis-plus.version>3.3.1</mybatis-plus.version>
<lombok.version>1.18.18</lombok.version>
<fastjson.version>1.2.83</fastjson.version>
<hutool.version>5.7.22</hutool.version>
<commons.lang3.version>3.12.0</commons.lang3.version>
<commons.io.version>2.11.0</commons.io.version>
</properties>
<!-- 核心依賴 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring.cloud.alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<!-- yml文件讀取pom文件的標簽值 -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!-- 配置打包插件 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.maven.plugin.version}</version>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- yml配置文件環(huán)境切換: dev/test/prod -->
<id>env</id>
<properties>
<profiles.active>dev</profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</project>4.hub-example添加模塊
hub-example添加的模塊也是聚合工程,主要包括:
(1)hub-dependencies,集中管理依賴。聚合工程,不寫代碼,可以刪除src目錄。其子模塊作用,在pom.xml文件引入常用的依賴。項目中其它工程只要引用hub-dependencies的子模塊就行。
(2)hub-common,管理封裝的通用模塊。聚合工程,不寫代碼,可以刪除src目錄。封裝的通用代碼放在這個模塊的子模塊中,給每個需要的工程引用。減少重復(fù)代碼,提供代碼可復(fù)用度。
(3)hub-ware,管理獨立運行的微服。每個業(yè)務(wù)規(guī)劃一個微服務(wù)。
以hub-dependencies添加子模塊為例,歸納以下步驟。
4.1 新建Module
選中hub-example,右鍵,依次選擇:New->Module,進入模塊配置對話框。

4.2 配置Module版本和方式
選擇Maven方式、選擇JDK版本。

4.3 配置Module基礎(chǔ)信息
配置hub-dependencies基礎(chǔ)信息。

4.4 添加剩余模塊
按照以上步驟,添加完成hub-common、hub-ware。
4.5 hub-example的pom.xml文件
hub-example的pom.xml文件中新增了<modules>標簽即如下。即hub-example管理以下包含的模塊。
<modules>
<module>hub-dependencies</module>
<module>hub-common</module>
<module>hub-ware</module>
</modules>5.hub-dependencies添加模塊
hub-dependencies添加hub-pf-a-dependencies和hub-pf-b-dependencies模塊。
5.1 新建Module
選中hub-dependencies,右鍵,依次選擇:New->Module,進入模塊配置對話框。

5.2 配置Module版本和方式
選擇Maven方式、選擇JDK版本。

5.3 配置Module基礎(chǔ)信息
配置hub-pf-a-dependencies基礎(chǔ)信息。

5.4 添加剩余模塊
按照以上步驟,添加完成hub-pf-b-dependencies。
5.5 hub-dependencies工程的pom.xml
添加模塊后,hub-dependencies工程的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hub-example</artifactId>
<groupId>com.hub</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hub-dependencies</artifactId>
<packaging>pom</packaging>
<modules>
<module>hub-pf-a-dependencies</module>
<module>hub-pf-b-dependencies</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>6.hub-common添加模塊
根據(jù)5.hub-dependencies添加模塊的步驟:
給hub-common添加example-common-entity和example-common-utils模塊。
6.1 hub-common工程的pom.xml
添加模塊后,hub-common工程的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hub-example</artifactId>
<groupId>com.hub</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hub-common</artifactId>
<packaging>pom</packaging>
<modules>
<module>example-common-entity</module>
<module>example-common-utils</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>7.hub-ware添加模塊
根據(jù)5.hub-dependencies添加模塊的步驟:
給hub-ware添加example-biz-a和example-biz-b模塊。
7.1 hub-ware工程的pom.xml
添加模塊后,hub-ware工程的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hub-example</artifactId>
<groupId>com.hub</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hub-ware</artifactId>
<packaging>pom</packaging>
<modules>
<module>example-biz-a</module>
<module>example-biz-b</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>8.hub-example工程列表
創(chuàng)建工程和添加子模塊后,工程hub-example工程列表。每個工程上一級和下一級都是通過pom.xml來維護管理關(guān)系。

9.hub-dependencies的子模塊添加依賴
為hub-dependencies模塊的子模塊hub-pf-a-dependencies和hub-pf-b-dependencies模塊添加依賴。
9.1 hub-pf-a-dependencies依賴
hub-pf-a-dependencies依賴,主要是基礎(chǔ)Jar包。
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hub-dependencies</artifactId>
<groupId>com.hub</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hub-pf-a-dependencies</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!--基礎(chǔ)工具-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
</dependencies>
</project>9.2 hub-pf-b-dependencies依賴
hub-pf-a-dependencies依賴,主要是操作數(shù)據(jù)庫的Jar包。
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hub-dependencies</artifactId>
<groupId>com.hub</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hub-pf-b-dependencies</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!--數(shù)據(jù)庫操作-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!--連接池-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!--PageHelper分頁插件-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
</dependencies>
</project>10.hub-common的子模塊添加依賴
為hub-common模塊的子模塊example-common-entity和example-common-utils模塊添加依賴。
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hub-common</artifactId>
<groupId>com.hub</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>example-common-utils</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.hub</groupId>
<artifactId>hub-pf-a-dependencies</artifactId>
<version>${hub.example.version}</version>
</dependency>
</dependencies>
</project>11.hub-ware添加依賴
為hub-ware模塊的子模塊example-biz-a模塊添加依賴。
11.1 example-biz-a依賴
example-biz-a需求:基礎(chǔ)依賴、數(shù)據(jù)庫操作依賴、springboot依賴。
注意:spring-boot、spring-cloud、spring-cloud-alibaba,在hub-example中已經(jīng)引入頂級依賴。在子工程中使用其模塊,可以不需要加版本號。
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hub-ware</artifactId>
<groupId>com.hub</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>example-biz-a</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!--springboot依賴-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--基礎(chǔ)依賴-->
<dependency>
<groupId>com.hub</groupId>
<artifactId>hub-pf-a-dependencies</artifactId>
<version>${hub.example.version}</version>
</dependency>
<!--數(shù)據(jù)庫操作依賴-->
<dependency>
<groupId>com.hub</groupId>
<artifactId>hub-pf-b-dependencies</artifactId>
<version>${hub.example.version}</version>
</dependency>
</dependencies>
<!--example-biz-a打包成可執(zhí)行Jar包-->
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.maven.plugin.version}</version>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
<executions>
<execution>
<!-- 把依賴包打包到可執(zhí)行的jar包中-->
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>11.2 example-biz-a打包成可執(zhí)行Jar包
example-biz-a打包成可執(zhí)行Jar包,則在pom.xml中添加配置。
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.maven.plugin.version}</version>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
<executions>
<execution>
<!-- 把依賴包打包到可執(zhí)行的jar包中-->
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>12.1在example-biz-a模塊中創(chuàng)建一個包com.htb,并在該包下創(chuàng)建一個啟動類BizAApplication

啟動類代碼如下:
package com.hub;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class BizAApplication {
public static void main(String[] args) {
SpringApplication.run(BizAApplication.class, args);
System.out.println("BizAApplication模塊啟動成功!!");
}
}
12.2在resources包下創(chuàng)建application.yml配置數(shù)據(jù)庫連接池和分頁插件參數(shù),代碼如下:
# tomcat端口號
server:
port: 8080
# spring配置
spring:
application:
# 程序名
name: example-biz-a
# 數(shù)據(jù)源配置
datasource:
druid:
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
# 配置mybatis
mybatis:
configuration:
# 將下劃線映射成駝峰命名
map-underscore-to-camel-case: true
# 指定日志的實現(xiàn)類,在控制臺顯示SQL語句
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 給實體類指定別名,在resultType中不用指定類全名,使用類簡單名字即可 (多個包使用逗號分隔)
#type-aliases-package: com.itheima.reggie.entity,com.itheima.reggie.dto
# 指定映射文件目錄 mybatis中實體映射文件xml所在的目錄
mapper-locations: classpath:mapper/*.xml
# 分頁組件
pagehelper:
# 合理化分頁,如果為true,pageNum < 1 會查詢第1頁 pageNum > 最后一頁 會查詢最后一頁的數(shù)據(jù)
# 如果設(shè)置為false,pageNum < 1 或 pageNum > 最后一頁 會返回空的數(shù)據(jù)
reasonable: true
# 指定使用哪種數(shù)據(jù)庫
helper-dialect: mysql12.3開啟動類BizAApplication,spring和pagehelper分頁組件啟動成功??!
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.3)
2024-02-25 11:49:31.216 INFO 12620 --- [ main] com.hub.BizAApplication : Starting BizAApplication using Java 1.8.0_221 on LAPTOP-MN4GQ4TM with PID 12620 (D:\java_code\2024test\hub-example\hub-ware\example-biz-a\target\classes started by HONOR in D:\java_code\2024test\hub-example)
2024-02-25 11:49:31.216 INFO 12620 --- [ main] com.hub.BizAApplication : No active profile set, falling back to default profiles: default
2024-02-25 11:49:31.682 WARN 12620 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.hub]' package. Please check your configuration.
2024-02-25 11:49:31.944 INFO 12620 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2024-02-25 11:49:31.944 INFO 12620 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2024-02-25 11:49:31.944 INFO 12620 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56]
2024-02-25 11:49:32.016 INFO 12620 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2024-02-25 11:49:32.016 INFO 12620 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 759 ms
2024-02-25 11:49:32.242 INFO 12620 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2024-02-25 11:49:32.309 INFO 12620 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
_ _ |_ _ _|_. ___ _ | _
| | |\/|_)(_| | |_\ |_)||_|_\
/ |
3.3.1
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
,------. ,--. ,--. ,--.
| .--. ' ,--,--. ,---. ,---. | '--' | ,---. | | ,---. ,---. ,--.--.
| '--' | ' ,-. | | .-. | | .-. : | .--. | | .-. : | | | .-. | | .-. : | .--'
| | --' \ '-' | ' '-' ' \ --. | | | | \ --. | | | '-' ' \ --. | |
`--' `--`--' .`- / `----' `--' `--' `----' `--' | |-' `----' `--'
`---' `--' is intercepting.
2024-02-25 11:49:32.765 INFO 12620 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2024-02-25 11:49:32.781 INFO 12620 --- [ main] com.hub.BizAApplication : Started BizAApplication in 1.861 seconds (JVM running for 2.476)
BizAApplication模塊啟動成功!!
Process finished with exit code -113總結(jié):避坑記錄:
13.1: pagehelper分頁組件版本問題導(dǎo)致循環(huán)依賴報錯原來版本為1.4.0.啟動效果為:

解決方法:將分頁組件版本改為1.4.1完美解決
13.2:數(shù)據(jù)庫連接池參數(shù)錯誤導(dǎo)致報錯:
數(shù)據(jù)庫連接池參數(shù)為:com.mysql.jdbc.Driver

解決方法:將數(shù)據(jù)庫連接池名稱改為:com.mysql.cj.jdbc.Driver
到此這篇關(guān)于Maven和IntelliJ IDEA搭建多模塊微服務(wù)的實現(xiàn)的文章就介紹到這了,更多相關(guān)Maven和IDEA搭建多模塊內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
聊聊spring boot的WebFluxTagsProvider的使用
這篇文章主要介紹了聊聊spring boot的WebFluxTagsProvider的使用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
SpringBoot ApplicationContextAware拓展接口使用詳解
當(dāng)一個類實現(xiàn)了這個接口(ApplicationContextAware)之后,這個類就可以方便獲得ApplicationContext中的所有bean。換句話說,就是這個類可以直接獲取spring配置文件中,所有有引用到的bean對象2023-04-04
IDEA的默認快捷鍵設(shè)置與Eclipse的常用快捷鍵的設(shè)置方法
這篇文章主要介紹了IDEA的默認快捷鍵設(shè)置與Eclipse的常用快捷鍵的設(shè)置方法,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-01-01
Spring ApplicationListener源碼解析
這篇文章主要為大家介紹了Spring ApplicationListener源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-01-01
基于bufferedreader的read()與readline()讀取出錯原因及解決
這篇文章主要介紹了bufferedreader的read()與readline()讀取出錯原因及解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-12-12
解決mapper無法自動裝配,未找到‘userMapper‘類型的Bean報錯問題
解決Spring Boot中Mapper無法自動裝配的問題,可以通過在Mapper接口上添加@Repository注解來解決,@Mapper和@Repository雖然都可以將類注冊為Bean,但@Mapper是MyBatis的注解,不需要在Spring中配置掃描地址,而@Repository是Spring的注解2024-11-11
Springboot以Repository方式整合Redis的方法
這篇文章主要介紹了Springboot以Repository方式整合Redis的方法,本文通過圖文并茂實例詳解給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04

