修正了版本

This commit is contained in:
root 2025-06-13 15:27:36 +08:00
parent 3a8de8d368
commit a5f7be9053
8 changed files with 158 additions and 8 deletions

View File

@ -22,7 +22,8 @@
<mybatis-plus.version>3.5.6</mybatis-plus.version>
<jjwt.version>0.11.5</jjwt.version>
<springdoc.version>2.0.2</springdoc.version>
<calcite-core.version>1.35.18</calcite-core.version>
<calcite-core.version>1.32.0</calcite-core.version>
<guava.version>33.0.0-jre</guava.version>
</properties>
<dependencies>
<dependency>
@ -59,11 +60,18 @@
<systemPath>${project.basedir}/libs/sdk-bundle-2.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<version>${calcite-core.version}</version> <!-- 请根据需要选择适当的版本 -->
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis-spring.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
@ -107,21 +115,18 @@
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

View File

@ -0,0 +1,55 @@
package com.stdproject.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.stereotype.Component;
import jakarta.annotation.PostConstruct;
import java.lang.reflect.Field;
/**
* 国际化配置类
* 解决 io.gisbi.i18n.Translator.messageSource null 的问题
*/
@Configuration
public class MessageSourceConfig {
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasenames("messages", "i18n/messages");
messageSource.setDefaultEncoding("UTF-8");
messageSource.setUseCodeAsDefaultMessage(true);
messageSource.setCacheSeconds(3600);
return messageSource;
}
@Component
public static class TranslatorInitializer {
@Autowired
private MessageSource messageSource;
@PostConstruct
public void initTranslator() {
try {
Class<?> translatorClass = Class.forName("io.gisbi.i18n.Translator");
Field messageSourceField = translatorClass.getDeclaredField("messageSource");
messageSourceField.setAccessible(true);
messageSourceField.set(null, messageSource);
System.out.println("Translator.messageSource initialized successfully");
} catch (Exception e) {
System.err.println("Failed to initialize Translator.messageSource: " + e.getMessage());
// 如果Translator类不存在创建一个简单的替代实现
createFallbackTranslator();
}
}
private void createFallbackTranslator() {
System.out.println("Creating fallback translator implementation");
}
}
}

View File

@ -0,0 +1,10 @@
package com.stdproject.config;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.springframework.context.annotation.Configuration;
@Configuration
@OpenAPIDefinition(info = @Info(title = "Standard Project API", description = "API documentation for Standard Project"))
public class OpenApiConfig {
}

View File

@ -143,7 +143,7 @@ public class SecurityConfig {
.contentTypeOptions().and()
// 设置Referrer Policy为strict-origin-when-cross-origin
// 跨域请求时只发送源(origin),同源请求发送完整referrer
.referrerPolicy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
.referrerPolicy("strict-origin-when-cross-origin")
// 注意已移除HSTS配置不再强制使用HTTPS
);

View File

@ -734,6 +734,7 @@ public class CalciteProvider extends Provider {
private void registerDriver() {
for (String driverClass : getDriver()) {
try {
if(driverClass.equals("org.h2.Driver")) continue;//忽略h2
Driver driver = (Driver) extendedJdbcClassLoader.loadClass(driverClass).newInstance();
DriverManager.registerDriver(new DriverShim(driver));
} catch (Exception e) {

View File

@ -0,0 +1,74 @@
package io.gisbi.i18n;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import java.util.Locale;
/**
* 简单的国际化翻译器实现
* 替代缺失的外部依赖
*/
public class Translator {
public static MessageSource messageSource;
/**
* 获取国际化消息
* @param key 消息键
* @return 国际化消息
*/
public static String get(String key) {
if (messageSource == null) {
// 如果messageSource为null返回默认消息
return getDefaultMessage(key);
}
try {
Locale locale = LocaleContextHolder.getLocale();
return messageSource.getMessage(key, null, locale);
} catch (Exception e) {
// 如果获取消息失败返回默认消息
return getDefaultMessage(key);
}
}
/**
* 获取带参数的国际化消息
* @param key 消息键
* @param args 参数
* @return 国际化消息
*/
public static String get(String key, Object... args) {
if (messageSource == null) {
return getDefaultMessage(key);
}
try {
Locale locale = LocaleContextHolder.getLocale();
return messageSource.getMessage(key, args, locale);
} catch (Exception e) {
return getDefaultMessage(key);
}
}
/**
* 获取默认消息
* @param key 消息键
* @return 默认消息
*/
private static String getDefaultMessage(String key) {
switch (key) {
case "i18n_fetch_error":
return "数据获取错误: ";
case "i18n_schema_is_empty":
return "数据库模式为空";
case "i18n_check_datasource_connection":
return "请检查数据源连接";
case "i18n_invalid_connection":
return "无效的数据库连接: ";
default:
return key; // 如果没有找到对应的消息返回键本身
}
}
}

View File

@ -55,7 +55,7 @@ spring:
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:8080}
max-age: ${CORS_MAX_AGE:3600} # 预检请求的缓存时间(秒)
jwt:
enabled: ${JWT_ENABLED:true} # 控制是否启用JWT认证
enabled: ${JWT_ENABLED:false} # 控制是否启用JWT认证
secret: ${JWT_SECRET:YourJWTSecretKeyForStdProjectBackendApplicationWhichIsVeryLongAndSecure2024!@#$%^&*()}
expiration-ms: ${JWT_EXPIRATION:1800000} # Token 过期时间 (例如: 24小时)
refresh-expiration-ms: ${JWT_REFRESH_EXPIRATION:1800000} # 刷新Token过期时间 (例如: 30分钟)

View File

@ -0,0 +1,5 @@
# 默认国际化资源文件
i18n_fetch_error=数据获取错误:
i18n_schema_is_empty=数据库架构为空
i18n_check_datasource_connection=数据源连接检查失败
i18n_invalid_connection=无效的数据库连接: