♻️Refactor: 修复若干配置项

This commit is contained in:
2025-10-15 18:53:02 +08:00
parent 2ba2711bf1
commit a203b4a684
9 changed files with 22 additions and 75 deletions
+3 -6
View File
@@ -9,25 +9,22 @@
<version>3.2.2</version> <version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>com.wonder</groupId> <groupId>com.wonder</groupId>
<artifactId>bi-backend</artifactId> <artifactId>bi-backend</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>bi-backend</name> <name>bi-backend</name>
<properties> <properties>
<java.version>21</java.version> <java.version>21</java.version>
</properties> </properties>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-amqp --> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-amqp -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId> <artifactId>spring-boot-starter-amqp</artifactId>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.rabbitmq/amqp-client -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>5.17.0</version>
</dependency>
<!-- https://github.com/redisson/redisson#quick-start --> <!-- https://github.com/redisson/redisson#quick-start -->
<dependency> <dependency>
<groupId>org.redisson</groupId> <groupId>org.redisson</groupId>
+2 -4
View File
@@ -1,12 +1,10 @@
# 建表脚本 # 建表脚本
# @author <a href="https://github.com/liyupi">程序员鱼皮</a>
# @from <a href="https://yupi.icu">编程导航知识星球</a>
-- 创建库 -- 创建库
create database if not exists yubi; create database if not exists bi;
-- 切换库 -- 切换库
use yubi; use bi;
-- 用户表 -- 用户表
create table if not exists user create table if not exists user
@@ -3,10 +3,12 @@ package com.wonder.bi.bizmq;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection; import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.ConnectionFactory;
import lombok.extern.slf4j.Slf4j;
/** /**
* 用于创建测试程序用到的交换机和队列(只用在程序启动前执行一次) * 用于创建测试程序用到的交换机和队列(只用在程序启动前执行一次)
*/ */
@Slf4j
public class BiInitMain { public class BiInitMain {
public static void main(String[] args) { public static void main(String[] args) {
@@ -15,18 +17,22 @@ public class BiInitMain {
factory.setHost("localhost"); factory.setHost("localhost");
factory.setVirtualHost("/bi"); factory.setVirtualHost("/bi");
factory.setUsername("wonder"); factory.setUsername("wonder");
factory.setPassword("Dn293830"); factory.setPassword("dn293830");
Connection connection = factory.newConnection(); Connection connection = factory.newConnection();
Channel channel = connection.createChannel(); Channel channel = connection.createChannel();
String EXCHANGE_NAME = BiMqConstant.BI_EXCHANGE_NAME; String EXCHANGE_NAME = BiMqConstant.BI_EXCHANGE_NAME;
channel.exchangeDeclare(EXCHANGE_NAME, "direct"); channel.exchangeDeclare(EXCHANGE_NAME, "direct");
log.info("交换机创建成功");
// 创建队列,随机分配一个队列名称 // 创建队列,随机分配一个队列名称
String queueName = BiMqConstant.BI_QUEUE_NAME; String queueName = BiMqConstant.BI_QUEUE_NAME;
channel.queueDeclare(queueName, true, false, false, null); channel.queueDeclare(queueName, true, false, false, null);
log.info("队列创建成功");
channel.queueBind(queueName, EXCHANGE_NAME, BiMqConstant.BI_ROUTING_KEY); channel.queueBind(queueName, EXCHANGE_NAME, BiMqConstant.BI_ROUTING_KEY);
log.info("队列绑定成功");
connection.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
} }
@@ -1,30 +0,0 @@
package com.wonder.bi.bizmq;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.wonder.bi.config.RabbitMqConfig;
/**
* 用于创建测试程序用到的交换机和队列(只用在程序启动前执行一次)
*/
public class MqInitMain {
public static void main(String[] args) {
try {
ConnectionFactory factory = RabbitMqConfig.newConnectionFactory();
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
String EXCHANGE_NAME = "code_exchange";
channel.exchangeDeclare(EXCHANGE_NAME, "direct");
// 创建队列,随机分配一个队列名称
String queueName = "code_queue";
channel.queueDeclare(queueName, true, false, false, null);
channel.queueBind(queueName, EXCHANGE_NAME, "my_routingKey");
} catch (Exception e) {
}
}
}
@@ -1,25 +0,0 @@
package com.wonder.bi.bizmq;
import com.rabbitmq.client.Channel;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class MyMessageConsumer {
// 指定程序监听的消息队列和确认机制
@SneakyThrows
@RabbitListener(queues = {"code_queue"}, ackMode = "MANUAL")
public void receiveMessage(String message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
log.info("receiveMessage message = {}", message);
channel.basicAck(deliveryTag, false);
}
}
@@ -27,7 +27,8 @@ public class RedissonConfig {
config.useSingleServer() config.useSingleServer()
.setDatabase(database) .setDatabase(database)
.setAddress("redis://" + host + ":" + port) .setAddress("redis://" + host + ":" + port)
.setPassword(password); .setPassword(password)
.setConnectTimeout(10000);
RedissonClient redisson = Redisson.create(config); RedissonClient redisson = Redisson.create(config);
return redisson; return redisson;
} }
+5 -5
View File
@@ -14,8 +14,8 @@ spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://47.121.181.112:3306/bi url: jdbc:mysql://47.121.181.112:3306/bi
username: wonder username: root
password: Dn293830 password: dn293830
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
druid: druid:
initial-size: 5 initial-size: 5
@@ -40,8 +40,8 @@ spring:
database: 1 database: 1
host: 47.121.181.112 host: 47.121.181.112
port: 6379 port: 6379
timeout: 5000 password: dn293830
password: Dn293830@redis
# 文件上传 # 文件上传
servlet: servlet:
@@ -51,7 +51,7 @@ spring:
rabbitmq: rabbitmq:
host: localhost host: localhost
port: 5672 port: 5672
password: Dn293830 password: dn293830
username: wonder username: wonder
virtual-host: /bi virtual-host: /bi
server: server:
@@ -13,6 +13,6 @@ class MyMessageProducerTest {
@Test @Test
void sendMessage() { void sendMessage() {
myMessageProducer.sendMessage("code_exchange", "my_routingKey", "你好呀"); myMessageProducer.sendMessage("amq.direct", "email.#", "hello@example.com");
} }
} }
@@ -19,6 +19,6 @@ class OosManagerTest {
@Test @Test
void putObject() { void putObject() {
// oosManager.putObject("test", "E:\\Doc\\7B\\yubi-backend-5f672bb635e37361d5a1ae0e5403e96f36317fd0\\src\\main\\resources\\banner.txt"); oosManager.putObject("test", "D:\\Desktop\\1.csv");
} }
} }