Bug description
With the following controller class
@RestController
@RequestMapping("/api/deepseek")
public class DeepSeekController {
private final DeepSeekChatModel chatModel;
public DeepSeekController(DeepSeekChatModel chatModel) {
this.chatModel = chatModel;
}
@GetMapping("/ai/generate")
public Map generate(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
return Map.of("generation", chatModel.call(message));
}
}
, I got a compilation error:
Parameter 0 of constructor in com.example.deepseekapi.DeepSeekController required a bean of type 'org.springframework.ai.deepseek.DeepSeekChatModel' that could not be found.
Environment Here is the build.gradle file:
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.4'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(24)
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
maven {
name = 'Central Portal Snapshots'
url = 'https://central.sonatype.com/repository/maven-snapshots/'
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'org.springframework.ai:spring-ai-starter-model-deepseek' <-- not available
implementation platform("org.springframework.ai:spring-ai-bom:1.0.0-SNAPSHOT")
// // Replace the following with the starter dependencies of specific modules you wish to use
implementation 'org.springframework.ai:spring-ai-deepseek'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
And here is the application.yml file
spring:
ai:
deepseek:
api-key: <api-key>
chat:
option:
model: deepseek-chat
temperature: 0.7
Steps to reproduce Following online document we can find, we set up a short project with Spring AI DeepSeek client. The documents we use are stated on this stackoverflow post.
Comment From: sobychacko
Why are you commenting out this line?
// implementation 'org.springframework.ai:spring-ai-starter-model-deepseek' <-- not available
That is the starter module that brings the auto-configuration for deepseek. Without that, you don't have a bean for DeepSeekChatModel
.
Comment From: vw98075
I already stated the reason in the original post, "not available". With the line up and other Spring AI dependencies commented out, there isn't any Spring AI dependencies in the external libraries panel of Intellji Idea.