| | |
| | | */ |
| | | @Slf4j |
| | | @SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package} |
| | | @SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"}) |
| | | @SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"}, |
| | | // 注意:这里排除的 Spring AI 自动配置,与各 profile 的 spring.autoconfigure.exclude 保持一致,但写在代码里的 |
| | | // 原因是:注解里的排除项与 yaml 里的排除项是「并集」,不会被外部 profile 配置文件覆盖,保证换任何 profile 都能正常启动。 |
| | | // 1. 向量库:AI 模块由 AiModelFactoryImpl 手动构建 VectorStore,三个自动配置同时启用会争抢 vectorStore 这个 bean 名 |
| | | // 2. 模型:AI 模块的模型由 AiModelFactoryImpl 手动构建(走 DB 里 ai_model 配置的 apiKey),不需要 Spring AI 的模型 Bean; |
| | | // 且未配置 api-key 时自动配置会在启动阶段直接抛「API key cannot be empty.」 |
| | | excludeName = { |
| | | // ========== 向量库自动配置 ========== |
| | | "org.springframework.ai.vectorstore.qdrant.autoconfigure.QdrantVectorStoreAutoConfiguration", |
| | | "org.springframework.ai.vectorstore.redis.autoconfigure.RedisVectorStoreAutoConfiguration", |
| | | "org.springframework.ai.vectorstore.milvus.autoconfigure.MilvusVectorStoreAutoConfiguration", |
| | | // ========== 模型自动配置 ========== |
| | | "org.springframework.ai.model.openai.autoconfigure.OpenAiChatAutoConfiguration", |
| | | "org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration", |
| | | "org.springframework.ai.model.openai.autoconfigure.OpenAiImageAutoConfiguration", |
| | | "org.springframework.ai.model.openai.autoconfigure.OpenAiAudioSpeechAutoConfiguration", |
| | | "org.springframework.ai.model.openai.autoconfigure.OpenAiAudioTranscriptionAutoConfiguration", |
| | | "org.springframework.ai.model.openai.autoconfigure.OpenAiModerationAutoConfiguration", |
| | | "org.springframework.ai.model.deepseek.autoconfigure.DeepSeekChatAutoConfiguration", |
| | | "org.springframework.ai.model.anthropic.autoconfigure.AnthropicChatAutoConfiguration", |
| | | "org.springframework.ai.model.google.genai.autoconfigure.chat.GoogleGenAiChatAutoConfiguration", |
| | | "org.springframework.ai.model.google.genai.autoconfigure.embedding.GoogleGenAiEmbeddingConnectionAutoConfiguration", |
| | | "org.springframework.ai.model.google.genai.autoconfigure.embedding.GoogleGenAiTextEmbeddingAutoConfiguration", |
| | | "org.springframework.ai.model.ollama.autoconfigure.OllamaApiAutoConfiguration", |
| | | "org.springframework.ai.model.ollama.autoconfigure.OllamaChatAutoConfiguration", |
| | | "org.springframework.ai.model.ollama.autoconfigure.OllamaEmbeddingAutoConfiguration", |
| | | "org.springframework.ai.model.stabilityai.autoconfigure.StabilityAiImageAutoConfiguration", |
| | | }) |
| | | public class YudaoServerApplication { |
| | | |
| | | public static void main(String[] args) { |