From 0ebf046e253b9d6eed92964034265893f9f0c8e3 Mon Sep 17 00:00:00 2001
From: Liu Wu <2780205363@qq.com>
Date: Tue, 8 Oct 2024 10:05:09 +0800
Subject: [PATCH] =?UTF-8?q?fix():=20=E4=BB=A3=E7=A0=81=E5=90=88=E5=B9=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...ot.autoconfigure.AutoConfiguration.imports | 1 +
.../event/listener/AddDatabaseListener.java | 2 +
cloud-modules/saas/pom.xml | 10 +--
.../java/com/muyu/server/SaasApplication.java | 12 +++-
.../service/impl/CarTypeServiceImpl.java | 2 +-
.../src/main/resources/bootstrap.yml | 70 -------------------
.../main/resources/mapper/CarTypeMapper.xml | 9 ---
.../resources/mapper/EnterpriseMapper.xml | 4 +-
8 files changed, 22 insertions(+), 88 deletions(-)
delete mode 100644 cloud-modules/saas/saas-server/src/main/resources/mapper/CarTypeMapper.xml
diff --git a/cloud-common/cloud-common-saas/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cloud-common/cloud-common-saas/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index 70148cf..4076e9f 100644
--- a/cloud-common/cloud-common-saas/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/cloud-common/cloud-common-saas/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1,3 +1,4 @@
com.muyu.cloud.common.saas.interceptor.WebMvcSaaSConfig
com.muyu.cloud.common.many.datasource.ManyDataSource
com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory
+com.muyu.cloud.common.many.datasource.init.InitDataSource
diff --git a/cloud-modules/cloud-event/src/main/java/com/muyu/event/listener/AddDatabaseListener.java b/cloud-modules/cloud-event/src/main/java/com/muyu/event/listener/AddDatabaseListener.java
index 45f6bdd..95e33bd 100644
--- a/cloud-modules/cloud-event/src/main/java/com/muyu/event/listener/AddDatabaseListener.java
+++ b/cloud-modules/cloud-event/src/main/java/com/muyu/event/listener/AddDatabaseListener.java
@@ -30,6 +30,8 @@ public class AddDatabaseListener implements EventListener {
});
+
+
}
@Override
diff --git a/cloud-modules/saas/pom.xml b/cloud-modules/saas/pom.xml
index a9e66f5..ec2653a 100644
--- a/cloud-modules/saas/pom.xml
+++ b/cloud-modules/saas/pom.xml
@@ -52,11 +52,11 @@
kafka-clients
-
- com.baomidou
- mybatis-plus-boot-starter
- 3.5.1
-
+
+
+
+
+
diff --git a/cloud-modules/saas/saas-server/src/main/java/com/muyu/server/SaasApplication.java b/cloud-modules/saas/saas-server/src/main/java/com/muyu/server/SaasApplication.java
index 7186808..4232b74 100644
--- a/cloud-modules/saas/saas-server/src/main/java/com/muyu/server/SaasApplication.java
+++ b/cloud-modules/saas/saas-server/src/main/java/com/muyu/server/SaasApplication.java
@@ -1,9 +1,14 @@
package com.muyu.server;
+import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
+import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
+import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+
/**
* saas模块启动类
* @author YuPing
@@ -11,7 +16,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @Version 1.0
* @Data 2024-09-28 17:34:31
*/
-@SpringBootApplication
+@SpringBootApplication(exclude = {
+ DataSourceAutoConfiguration.class,
+ DruidDataSourceAutoConfigure.class,
+ DynamicDataSourceAutoConfiguration.class
+})
+@EnableCustomConfig
@EnableMyFeignClients
public class SaasApplication {
public static void main(String[] args) {
diff --git a/cloud-modules/saas/saas-server/src/main/java/com/muyu/server/service/impl/CarTypeServiceImpl.java b/cloud-modules/saas/saas-server/src/main/java/com/muyu/server/service/impl/CarTypeServiceImpl.java
index 163062a..e1a584c 100644
--- a/cloud-modules/saas/saas-server/src/main/java/com/muyu/server/service/impl/CarTypeServiceImpl.java
+++ b/cloud-modules/saas/saas-server/src/main/java/com/muyu/server/service/impl/CarTypeServiceImpl.java
@@ -23,7 +23,7 @@ import java.util.List;
@Service
public class CarTypeServiceImpl extends ServiceImpl implements CarTypeService{
- @Resource
+ @Autowired
private CarTypeMapper carTypeMapper;
diff --git a/cloud-modules/saas/saas-server/src/main/resources/bootstrap.yml b/cloud-modules/saas/saas-server/src/main/resources/bootstrap.yml
index 7ce8b80..02b5edc 100644
--- a/cloud-modules/saas/saas-server/src/main/resources/bootstrap.yml
+++ b/cloud-modules/saas/saas-server/src/main/resources/bootstrap.yml
@@ -11,76 +11,6 @@ nacos:
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring
spring:
- kafka:
- producer:
- # Kafka服务器
- bootstrap-servers: 150.158.33.234:9092
- # 开启事务,必须在开启了事务的方法中发送,否则报错
- transaction-id-prefix: kafkaTx-
- # 发生错误后,消息重发的次数,开启事务必须设置大于0。
- retries: 3
- # acks=0 : 生产者在成功写入消息之前不会等待任何来自服务器的响应。
- # acks=1 : 只要集群的首领节点收到消息,生产者就会收到一个来自服务器成功响应。
- # acks=all :只有当所有参与复制的节点全部收到消息时,生产者才会收到一个来自服务器的成功响应。
- acks: all
- # 开启事务时,必须设置为all
- # 当有多个消息需要被发送到同一个分区时,生产者会把它们放在同一个批次里。该参数指定了一个批次可以使用的内存大小,按照字节数计算。
- batch-size: 16384
- # 生产者内存缓冲区的大小。
- buffer-memory: 1024000
- # 键的序列化方式
- key-serializer: org.apache.kafka.common.serialization.StringSerializer
- # 值的序列化方式(建议使用Json,这种序列化方式可以无需额外配置传输实体类)
- value-serializer: org.apache.kafka.common.serialization.StringSerializer
- consumer:
- # Kafka服务器
- group-id: my-kafka
- # 自动提交的时间间隔 在spring boot 2.X 版本中这里采用的是值的类型为Duration 需要符合特定的格式,如1S,1M,2H,5D
- #auto-commit-interval: 2s
- # 该属性指定了消费者在读取一个没有偏移量的分区或者偏移量无效的情况下该作何处理:
- # earliest:当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,从头开始消费分区的记录
- # latest:当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,消费新产生的该分区下的数据(在消费者启动之后生成的记录)
- # none:当各分区都存在已提交的offset时,从提交的offset开始消费;只要有一个分区不存在已提交的offset,则抛出异常
- auto-offset-reset: latest
- # 是否自动提交偏移量,默认值是true,为了避免出现重复数据和数据丢失,可以把它设置为false,然后手动提交偏移量
- enable-auto-commit: true
- # 键的反序列化方式
- #key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
- key-deserializer: org.apache.kafka.common.serialization.StringSerializer
- # 值的反序列化方式(建议使用Json,这种序列化方式可以无需额外配置传输实体类)
- value-deserializer: org.apache.kafka.common.serialization.StringSerializer
- # 这个参数定义了poll方法最多可以拉取多少条消息,默认值为500。如果在拉取消息的时候新消息不足500条,那有多少返回多少;如果超过500条,每次只返回500。
- # 这个默认值在有些场景下太大,有些场景很难保证能够在5min内处理完500条消息,
- # 如果消费者无法在5分钟内处理完500条消息的话就会触发reBalance,
- # 然后这批消息会被分配到另一个消费者中,还是会处理不完,这样这批消息就永远也处理不完。
- # 要避免出现上述问题,提前评估好处理一条消息最长需要多少时间,然后覆盖默认的max.poll.records参数
- # 注:需要开启BatchListener批量监听才会生效,如果不开启BatchListener则不会出现reBalance情况
- max-poll-records: 500
- bootstrap-servers: 150.158.33.234:9092
- auto-commit-interval: 5000
- fetch-max-wait: 500
- fetch-min-size: 1
- heartbeat-interval: 3000
- properties:
- # 两次poll之间的最大间隔,默认值为5分钟。如果超过这个间隔会触发reBalance
- max:
- poll:
- interval:
- ms: 600000
- # 当broker多久没有收到consumer的心跳请求后就触发reBalance,默认值是10s
- session:
- timeout:
- ms: 10000
- listener:
- # 在侦听器容器中运行的线程数,一般设置为 机器数*分区数
- concurrency: 4
- # 自动提交关闭,需要设置手动消息确认
- ack-mode: manual_immediate
- # 消费监听接口监听的主题不存在时,默认会报错,所以设置为false忽略错误
- missing-topics-fatal: false
- # 两次poll之间的最大间隔,默认值为5分钟。如果超过这个间隔会触发reBalance
- poll-timeout: 600000
-
mvc:
pathmatch:
matching-strategy: ant_path_matcher
diff --git a/cloud-modules/saas/saas-server/src/main/resources/mapper/CarTypeMapper.xml b/cloud-modules/saas/saas-server/src/main/resources/mapper/CarTypeMapper.xml
deleted file mode 100644
index 63274cf..0000000
--- a/cloud-modules/saas/saas-server/src/main/resources/mapper/CarTypeMapper.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
diff --git a/cloud-modules/saas/saas-server/src/main/resources/mapper/EnterpriseMapper.xml b/cloud-modules/saas/saas-server/src/main/resources/mapper/EnterpriseMapper.xml
index 76e2c13..aa32d53 100644
--- a/cloud-modules/saas/saas-server/src/main/resources/mapper/EnterpriseMapper.xml
+++ b/cloud-modules/saas/saas-server/src/main/resources/mapper/EnterpriseMapper.xml
@@ -6,7 +6,7 @@
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
-->
-
+
-
+
insert into tb_enterprise
set enterprise_name = #{enterpriseName},
enterprise_car_count = #{enterpriseCarCount},