♻️Refactor: 修复若干配置项
This commit is contained in:
+3
-6
@@ -9,25 +9,22 @@
|
||||
<version>3.2.2</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.wonder</groupId>
|
||||
<artifactId>bi-backend</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>bi-backend</name>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-amqp -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</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 -->
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.wonder.bi.bizmq;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 用于创建测试程序用到的交换机和队列(只用在程序启动前执行一次)
|
||||
*/
|
||||
@Slf4j
|
||||
public class BiInitMain {
|
||||
|
||||
public static void main(String[] args) {
|
||||
@@ -15,18 +17,22 @@ public class BiInitMain {
|
||||
factory.setHost("localhost");
|
||||
factory.setVirtualHost("/bi");
|
||||
factory.setUsername("wonder");
|
||||
factory.setPassword("Dn293830");
|
||||
factory.setPassword("dn293830");
|
||||
Connection connection = factory.newConnection();
|
||||
Channel channel = connection.createChannel();
|
||||
String EXCHANGE_NAME = BiMqConstant.BI_EXCHANGE_NAME;
|
||||
channel.exchangeDeclare(EXCHANGE_NAME, "direct");
|
||||
log.info("交换机创建成功");
|
||||
|
||||
// 创建队列,随机分配一个队列名称
|
||||
String queueName = BiMqConstant.BI_QUEUE_NAME;
|
||||
channel.queueDeclare(queueName, true, false, false, null);
|
||||
log.info("队列创建成功");
|
||||
channel.queueBind(queueName, EXCHANGE_NAME, BiMqConstant.BI_ROUTING_KEY);
|
||||
log.info("队列绑定成功");
|
||||
connection.close();
|
||||
} 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()
|
||||
.setDatabase(database)
|
||||
.setAddress("redis://" + host + ":" + port)
|
||||
.setPassword(password);
|
||||
.setPassword(password)
|
||||
.setConnectTimeout(10000);
|
||||
RedissonClient redisson = Redisson.create(config);
|
||||
return redisson;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://47.121.181.112:3306/bi
|
||||
username: wonder
|
||||
password: Dn293830
|
||||
username: root
|
||||
password: dn293830
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
initial-size: 5
|
||||
@@ -40,8 +40,8 @@ spring:
|
||||
database: 1
|
||||
host: 47.121.181.112
|
||||
port: 6379
|
||||
timeout: 5000
|
||||
password: Dn293830@redis
|
||||
password: dn293830
|
||||
|
||||
|
||||
# 文件上传
|
||||
servlet:
|
||||
@@ -51,7 +51,7 @@ spring:
|
||||
rabbitmq:
|
||||
host: localhost
|
||||
port: 5672
|
||||
password: Dn293830
|
||||
password: dn293830
|
||||
username: wonder
|
||||
virtual-host: /bi
|
||||
server:
|
||||
|
||||
@@ -13,6 +13,6 @@ class MyMessageProducerTest {
|
||||
|
||||
@Test
|
||||
void sendMessage() {
|
||||
myMessageProducer.sendMessage("code_exchange", "my_routingKey", "你好呀");
|
||||
myMessageProducer.sendMessage("amq.direct", "email.#", "hello@example.com");
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,6 @@ class OosManagerTest {
|
||||
|
||||
@Test
|
||||
void putObject() {
|
||||
// oosManager.putObject("test", "E:\\Doc\\7B\\yubi-backend-5f672bb635e37361d5a1ae0e5403e96f36317fd0\\src\\main\\resources\\banner.txt");
|
||||
oosManager.putObject("test", "D:\\Desktop\\1.csv");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user