Compare commits
2 Commits
e7c1a76ea3
...
28b5ca1dfc
Author | SHA1 | Date | |
---|---|---|---|
28b5ca1dfc | |||
56bfdad0c0 |
@ -79,28 +79,15 @@ redis的服务器配置
|
|||||||
|
|
||||||
## 2025年5月22日
|
## 2025年5月22日
|
||||||
### ✅ 今日完成
|
### ✅ 今日完成
|
||||||
服务发布逻辑但未配置nacos
|
服务发布,拦截器部分功能
|
||||||
|
|
||||||
### 🚧 进行中
|
### 🚧 进行中
|
||||||
配置nacos
|
拦截器等待队列算法
|
||||||
|
|
||||||
### ⚠️ 问题/障碍
|
### ⚠️ 问题/障碍
|
||||||
暂无
|
不知道怎么优先分配等待队列中任务
|
||||||
|
|
||||||
### 📅 明日计划
|
### 📅 明日计划
|
||||||
完成配置
|
完成拦截器功能
|
||||||
|
|
||||||
|
|
||||||
## 2025年5月23日
|
|
||||||
### ✅ 今日完成
|
|
||||||
完成配置nacos
|
|
||||||
|
|
||||||
### 🚧 进行中
|
|
||||||
使项目链接上nacos
|
|
||||||
|
|
||||||
### ⚠️ 问题/障碍
|
|
||||||
暂无
|
|
||||||
|
|
||||||
### 📅 明日计划
|
|
||||||
完成服务发布功能
|
|
||||||
|
|
||||||
|
88
pom.xml
88
pom.xml
@ -2,34 +2,51 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.2.5</version>
|
<version>3.1.5</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>com.bipt</groupId>
|
<groupId>com.bipt</groupId>
|
||||||
<artifactId>intelligent-application-orchestration-service</artifactId>
|
<artifactId>intelligent-application-orchestration-service</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>intelligent-application-orchestration-service</name>
|
<name>intelligent-application-orchestration-service</name>
|
||||||
<description>intelligent-application-orchestration-service</description>
|
<description>intelligent-application-orchestration-service</description>
|
||||||
<url/>
|
<url/>
|
||||||
<licenses>
|
|
||||||
<license/>
|
|
||||||
</licenses>
|
|
||||||
<developers>
|
|
||||||
<developer/>
|
|
||||||
</developers>
|
|
||||||
<scm>
|
|
||||||
<connection/>
|
|
||||||
<developerConnection/>
|
|
||||||
<tag/>
|
|
||||||
<url/>
|
|
||||||
</scm>
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
|
<!-- 添加 Spring Cloud 版本控制 -->
|
||||||
|
<spring-cloud.version>2022.0.4</spring-cloud.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<!-- 依赖管理:统一控制 Spring Cloud 和 Alibaba 版本 -->
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<!-- Spring Cloud 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Spring Cloud Alibaba 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
<version>2022.0.0.0</version> <!-- 适配 Spring Boot 3.1.x 的正确版本 -->
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Spring Boot 基础依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
@ -38,54 +55,53 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 数据库驱动 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.kingbase8</groupId>
|
||||||
|
<artifactId>kingbase8</artifactId>
|
||||||
|
<version>9.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 工具类依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.38</version>
|
<version>1.18.38</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--分页查询-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
<version>1.4.7</version>
|
<version>1.4.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--nacos相关依赖-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.nacos</groupId>
|
|
||||||
<artifactId>nacos-client</artifactId>
|
|
||||||
<version>2.2.1</version> <!-- 与服务端版本保持一致 -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
<version>2021.0.1.0</version> <!-- 根据实际版本调整 -->
|
|
||||||
</dependency>
|
|
||||||
<!--swagger相关依赖,生成接口文档-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springdoc</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
<version>2.3.0</version> <!-- 最新稳定版 -->
|
<version>2.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--KingbaseES V8/V9 数据库 JDBC 驱动-->
|
<!-- Nacos 配置依赖(移除手动版本,由上方依赖管理控制) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.kingbase8</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>kingbase8</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
<version>9.0.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Spring Boot 3.x 必须的 Bootstrap 依赖(无需版本号) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 测试依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
@ -110,6 +126,9 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<!-- 显式指定 Java 21 编译 -->
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
<annotationProcessorPaths>
|
<annotationProcessorPaths>
|
||||||
<path>
|
<path>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@ -133,5 +152,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -4,11 +4,13 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
@MapperScan("com.bipt.intelligentapplicationorchestrationservice.mapper")//指定扫描Mapper接口的包
|
@MapperScan("com.bipt.intelligentapplicationorchestrationservice.mapper")//指定扫描Mapper接口的包
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
|
@EnableDiscoveryClient
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class IntelligentApplicationOrchestrationServiceApplication {
|
public class IntelligentApplicationOrchestrationServiceApplication {
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RefreshScope // 支持配置动态刷新
|
|
||||||
public class ConfigController {
|
|
||||||
@Value("${example.config:默认值}")
|
|
||||||
private String configValue;
|
|
||||||
|
|
||||||
@GetMapping("/config")
|
|
||||||
public String getConfig() {
|
|
||||||
return "配置值: " + configValue;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,8 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.config.RedisConfiguration;
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.util.NacosServiceUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -24,11 +24,9 @@ public class publishController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisTemplate redisTemplate;
|
private RedisTemplate redisTemplate;
|
||||||
/**
|
@Autowired
|
||||||
* 新增请求发布
|
private NacosServiceUtil nacosServiceUtil;
|
||||||
* @param servicePublishDTO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Operation(summary ="新增发布请求")
|
@Operation(summary ="新增发布请求")
|
||||||
@Transactional
|
@Transactional
|
||||||
@ -36,8 +34,22 @@ public class publishController {
|
|||||||
log.info("模型发布请求:{}", servicePublishDTO);
|
log.info("模型发布请求:{}", servicePublishDTO);
|
||||||
publishService.save(servicePublishDTO);
|
publishService.save(servicePublishDTO);
|
||||||
Long modelId = servicePublishDTO.getModelId();
|
Long modelId = servicePublishDTO.getModelId();
|
||||||
|
String key = "Model_" + modelId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
nacosServiceUtil.registerService(
|
||||||
|
servicePublishDTO.getModelId().toString(),
|
||||||
|
servicePublishDTO.getIp(),
|
||||||
|
8080
|
||||||
|
);
|
||||||
|
log.info("Nacos服务注册成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Nacos服务注册失败", e);
|
||||||
|
}
|
||||||
|
|
||||||
return OptResult.success();
|
return OptResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@ import lombok.NoArgsConstructor;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hky
|
* @author hky
|
||||||
*/
|
*/
|
||||||
@ -21,5 +19,5 @@ public class ServicePublishDTO implements Serializable {
|
|||||||
private Long modelId;
|
private Long modelId;
|
||||||
private String apiUrl;
|
private String apiUrl;
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
private List<String> ip;
|
private String ip;
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,15 @@ public class PublishServiceImpl implements PublishService {
|
|||||||
publishMapper.insert(servicePublishDTO);
|
publishMapper.insert(servicePublishDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查找配置信息
|
||||||
|
* @param modelId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getByModelId(Long modelId) {
|
||||||
|
return publishMapper.getById(modelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,4 +9,5 @@ public interface PublishService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String getByModelId(Long modelId);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.util;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.naming.NamingFactory;
|
||||||
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class NacosServiceUtil {
|
||||||
|
@Value("${spring.cloud.nacos.discovery.server-addr}")
|
||||||
|
private String nacosServerAddr;
|
||||||
|
|
||||||
|
public void registerService(String serviceName, String ip, int port) throws Exception {
|
||||||
|
NamingService naming = NamingFactory.createNamingService(nacosServerAddr);
|
||||||
|
Instance instance = new Instance();
|
||||||
|
instance.setIp(ip);
|
||||||
|
instance.setPort(port);
|
||||||
|
naming.registerInstance(serviceName, instance);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,3 @@
|
|||||||
spring.application.name=intelligent-application-orchestration-service
|
|
||||||
|
|
||||||
|
|
||||||
# 数据库配置
|
# 数据库配置
|
||||||
spring.datasource.url=jdbc:kingbase8://116.205.121.200:54321/Ipz
|
spring.datasource.url=jdbc:kingbase8://116.205.121.200:54321/Ipz
|
||||||
@ -10,32 +8,14 @@ spring.datasource.hikari.maximum-pool-size=10
|
|||||||
spring.datasource.hikari.minimum-idle=5
|
spring.datasource.hikari.minimum-idle=5
|
||||||
spring.datasource.hikari.connection-timeout=30000
|
spring.datasource.hikari.connection-timeout=30000
|
||||||
|
|
||||||
# SQL映射文件路径配置
|
# MyBatis配置
|
||||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||||
# 配置实体类别名所在包
|
|
||||||
mybatis.type-aliases-package=com.bipt.intelligentapplicationorchestrationservice.pojo
|
mybatis.type-aliases-package=com.bipt.intelligentapplicationorchestrationservice.pojo
|
||||||
# 开启驼峰命名转换
|
|
||||||
mybatis.configuration.map-underscore-to-camel-case=true
|
mybatis.configuration.map-underscore-to-camel-case=true
|
||||||
|
|
||||||
# Redis服务器地址
|
# Redis配置
|
||||||
spring.data.redis.host=116.205.121.200
|
spring.data.redis.host=116.205.121.200
|
||||||
# Redis服务器端口
|
|
||||||
spring.data.redis.port=6379
|
spring.data.redis.port=6379
|
||||||
# Redis密码(如果有)
|
|
||||||
spring.data.redis.password=Jbjhhzstsl97@
|
spring.data.redis.password=Jbjhhzstsl97@
|
||||||
# Redis数据库索引(默认为0)
|
spring.data.redis.database=0
|
||||||
spring.data.redis.database = 0
|
spring.data.redis.timeout=3000
|
||||||
# 连接超时时间(毫秒)
|
|
||||||
spring.data.redis.timeout = 3000
|
|
||||||
|
|
||||||
|
|
||||||
# Nacos 配置中心地址
|
|
||||||
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
|
|
||||||
# 配置文件前缀(默认为应用名)
|
|
||||||
spring.cloud.nacos.config.prefix=intelligent-application-orchestration-service
|
|
||||||
# 配置文件后缀
|
|
||||||
spring.cloud.nacos.config.file-extension=properties
|
|
||||||
# 配置组
|
|
||||||
spring.cloud.nacos.config.group=DEFAULT_GROUP
|
|
||||||
# 启用 Nacos 配置
|
|
||||||
spring.cloud.nacos.config.enabled=true
|
|
10
src/main/resources/bootstrap.properties
Normal file
10
src/main/resources/bootstrap.properties
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 应用名称(必须与Nacos配置的dataId前缀一致)
|
||||||
|
spring.application.name=intelligent-application-orchestration-service
|
||||||
|
|
||||||
|
# Nacos配置中心地址(引导阶段加载配置)
|
||||||
|
spring.cloud.nacos.config.server-addr=192.168.100.1:8848
|
||||||
|
spring.cloud.nacos.config.data-id=${spring.application.name}.properties
|
||||||
|
spring.cloud.nacos.config.group=DEFAULT_GROUP
|
||||||
|
|
||||||
|
# Nacos服务注册地址(引导阶段注册服务)
|
||||||
|
spring.cloud.nacos.discovery.server-addr=192.168.100.1:8848
|
Reference in New Issue
Block a user