修正了版本
This commit is contained in:
parent
3a8de8d368
commit
a5f7be9053
@ -22,7 +22,8 @@
|
|||||||
<mybatis-plus.version>3.5.6</mybatis-plus.version>
|
<mybatis-plus.version>3.5.6</mybatis-plus.version>
|
||||||
<jjwt.version>0.11.5</jjwt.version>
|
<jjwt.version>0.11.5</jjwt.version>
|
||||||
<springdoc.version>2.0.2</springdoc.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>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -59,11 +60,18 @@
|
|||||||
<systemPath>${project.basedir}/libs/sdk-bundle-2.0.jar</systemPath>
|
<systemPath>${project.basedir}/libs/sdk-bundle-2.0.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.calcite</groupId>
|
||||||
|
<artifactId>calcite-core</artifactId>
|
||||||
|
<version>${calcite-core.version}</version> <!-- 请根据需要选择适当的版本 -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mybatis</groupId>
|
<groupId>org.mybatis</groupId>
|
||||||
<artifactId>mybatis-spring</artifactId>
|
<artifactId>mybatis-spring</artifactId>
|
||||||
<version>${mybatis-spring.version}</version>
|
<version>${mybatis-spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
@ -107,21 +115,18 @@
|
|||||||
<version>${springdoc.version}</version>
|
<version>${springdoc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</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>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-test</artifactId>
|
<artifactId>spring-security-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 {
|
||||||
|
}
|
@ -143,7 +143,7 @@ public class SecurityConfig {
|
|||||||
.contentTypeOptions().and()
|
.contentTypeOptions().and()
|
||||||
// 设置Referrer Policy为strict-origin-when-cross-origin
|
// 设置Referrer Policy为strict-origin-when-cross-origin
|
||||||
// 跨域请求时只发送源(origin),同源请求发送完整referrer
|
// 跨域请求时只发送源(origin),同源请求发送完整referrer
|
||||||
.referrerPolicy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
|
.referrerPolicy("strict-origin-when-cross-origin")
|
||||||
// 注意:已移除HSTS配置,不再强制使用HTTPS
|
// 注意:已移除HSTS配置,不再强制使用HTTPS
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -734,6 +734,7 @@ public class CalciteProvider extends Provider {
|
|||||||
private void registerDriver() {
|
private void registerDriver() {
|
||||||
for (String driverClass : getDriver()) {
|
for (String driverClass : getDriver()) {
|
||||||
try {
|
try {
|
||||||
|
if(driverClass.equals("org.h2.Driver")) continue;//忽略h2
|
||||||
Driver driver = (Driver) extendedJdbcClassLoader.loadClass(driverClass).newInstance();
|
Driver driver = (Driver) extendedJdbcClassLoader.loadClass(driverClass).newInstance();
|
||||||
DriverManager.registerDriver(new DriverShim(driver));
|
DriverManager.registerDriver(new DriverShim(driver));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
74
backend/src/main/java/io/gisbi/i18n/Translator.java
Normal file
74
backend/src/main/java/io/gisbi/i18n/Translator.java
Normal 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; // 如果没有找到对应的消息,返回键本身
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -55,7 +55,7 @@ spring:
|
|||||||
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:8080}
|
allowed-origins: ${CORS_ALLOWED_ORIGINS:http://localhost:3000,http://localhost:8080}
|
||||||
max-age: ${CORS_MAX_AGE:3600} # 预检请求的缓存时间(秒)
|
max-age: ${CORS_MAX_AGE:3600} # 预检请求的缓存时间(秒)
|
||||||
jwt:
|
jwt:
|
||||||
enabled: ${JWT_ENABLED:true} # 控制是否启用JWT认证
|
enabled: ${JWT_ENABLED:false} # 控制是否启用JWT认证
|
||||||
secret: ${JWT_SECRET:YourJWTSecretKeyForStdProjectBackendApplicationWhichIsVeryLongAndSecure2024!@#$%^&*()}
|
secret: ${JWT_SECRET:YourJWTSecretKeyForStdProjectBackendApplicationWhichIsVeryLongAndSecure2024!@#$%^&*()}
|
||||||
expiration-ms: ${JWT_EXPIRATION:1800000} # Token 过期时间 (例如: 24小时)
|
expiration-ms: ${JWT_EXPIRATION:1800000} # Token 过期时间 (例如: 24小时)
|
||||||
refresh-expiration-ms: ${JWT_REFRESH_EXPIRATION:1800000} # 刷新Token过期时间 (例如: 30分钟)
|
refresh-expiration-ms: ${JWT_REFRESH_EXPIRATION:1800000} # 刷新Token过期时间 (例如: 30分钟)
|
||||||
|
5
backend/src/main/resources/messages.properties
Normal file
5
backend/src/main/resources/messages.properties
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# 默认国际化资源文件
|
||||||
|
i18n_fetch_error=数据获取错误:
|
||||||
|
i18n_schema_is_empty=数据库架构为空
|
||||||
|
i18n_check_datasource_connection=数据源连接检查失败
|
||||||
|
i18n_invalid_connection=无效的数据库连接:
|
Loading…
Reference in New Issue
Block a user