fix: Spring 多构造器类显式 @Autowired 标注 + V95 迁移兼容 MySQL 8.4
Build Backend JAR / build (push) Has been cancelled
Build Backend JAR / build (push) Has been cancelled
- CapacityPlanService / ExternalCallMetricsRecorder / ZiniaoClientImpl: 双构造器(生产 + 测试入口)导致 Spring 6 不自动推断构造器注入, 启动报 'No default constructor found';生产构造器显式加 @Autowired - V95:shop_key 列 V85 建表时已有,原 ADD COLUMN shop_key 会报 duplicate column;MySQL 8.4 不支持 ADD COLUMN IF NOT EXISTS,改 information_schema 动态 SQL;shop_key 缩到 VARCHAR(255) 以容纳 (shop_key, business_date) 唯一键(1000 在 utf8mb4 下超 3072 字节 索引上限);删除多余行改为单表 DELETE
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.nanri.aiimage.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -20,7 +21,8 @@ public class CapacityPlanService implements CommandLineRunner {
|
||||
private final CapacityPlanProperties properties;
|
||||
private final long machineMaxMemoryBytes;
|
||||
|
||||
/** 供测试注入机器内存字节数;生产构造时取 Runtime.maxMemory()。 */
|
||||
/** 生产构造:测试用双参构造器存在,Spring 不会自动推断,必须显式 @Autowired。 */
|
||||
@Autowired
|
||||
public CapacityPlanService(CapacityPlanProperties properties) {
|
||||
this(properties, maxMemoryBytes());
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.micrometer.core.instrument.DistributionSummary;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.Timer;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -28,6 +29,8 @@ public class ExternalCallMetricsRecorder {
|
||||
|
||||
private final ObjectProvider<MeterRegistry> meterRegistryProvider;
|
||||
|
||||
/** 生产构造:测试用 MeterRegistry 构造器存在,Spring 不会自动推断,必须显式 @Autowired。 */
|
||||
@Autowired
|
||||
public ExternalCallMetricsRecorder(ObjectProvider<MeterRegistry> meterRegistryProvider) {
|
||||
this.meterRegistryProvider = meterRegistryProvider;
|
||||
}
|
||||
|
||||
+3
@@ -6,6 +6,7 @@ import com.nanri.aiimage.common.exception.BusinessException;
|
||||
import com.nanri.aiimage.config.ZiniaoProperties;
|
||||
import com.nanri.aiimage.modules.ziniao.model.cache.ZiniaoShopCacheDto;
|
||||
import com.nanri.aiimage.modules.ziniao.model.vo.ZiniaoStaffItemVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
@@ -26,6 +27,8 @@ public class ZiniaoClientImpl implements ZiniaoClient {
|
||||
private final ObjectMapper objectMapper;
|
||||
private final com.nanri.aiimage.metrics.ExternalCallMetricsRecorder externalCallMetrics;
|
||||
|
||||
/** 生产构造:双构造器下 Spring 不会自动推断,必须显式 @Autowired。 */
|
||||
@Autowired
|
||||
public ZiniaoClientImpl(ZiniaoProperties ziniaoProperties, ObjectMapper objectMapper) {
|
||||
this(ziniaoProperties, objectMapper, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user